Skip to content
Fixedmark

Databases · 11 min read

Updated

Redis Cloud IP Allow List from Serverless Functions

Paid Redis Cloud and Upstash plans can restrict a database to listed IPv4 addresses or CIDR ranges. Node-based ElastiCache clusters are reachable only from inside their VPC. Serverless functions have no fixed outbound IP, so send the Redis TCP connection through a SOCKS5 proxy with static IPs, add those IPs as /32 entries, keep TLS on, and then remove `0.0.0.0/0`.

On this page

What each managed Redis lets you restrict

The three common managed Redis services use three different models. Redis Cloud and Upstash filter connections by source address at the database. ElastiCache relies on network placement. A node-based cluster lives in a VPC, and security groups decide who inside AWS can reach it.

Network access controls on managed Redis, November 2026
ServiceControlPlansNotes
Redis CloudDatabase CIDR allow listPaid Essentials and Pro, not Free4 to 32 entries on Essentials depending on the plan, up to 32 on Pro. Applies to the public and the private endpoint.
Upstash RedisIP allowlist (one IPv4 address or a CIDR block per entry)All plans except FreeOpen to every address until you add the first range. IPv4 only.
ElastiCache, node-basedVPC security groupsAllNo public IP. Reachable from inside the VPC or a connected network only.
ElastiCache Serverless, public endpointIAM authenticationValkey 9.0 and laterReachable from the internet. No documented source-IP condition.

Redis Cloud's network security page compares its allow list to using iptables to limit access to a host. That is a fair model for Upstash too. The filter looks at the address the connection comes from. It does not care which client library you use or which password you send.

Why serverless code cannot go on the list

An allow list needs an address you can name. Functions on Vercel, Netlify, Cloud Run, and Lambda outside a VPC send traffic from shared pools that change with deploys, regions, and scaling. Upstash's own security docs say you cannot know the IP addresses of serverless platforms such as AWS Lambda and Vercel functions. The post on why serverless egress IPs change covers each platform's behaviour.

So many teams never turn the list on. On Upstash, that is the default state. With no ranges, any IP can connect. Redis Cloud's free plan has no list at all. Either way, the password or token in your environment variables becomes the only control, and any leaked copy of it works from anywhere.

Listing a cloud's published ranges does not fix this. Those ranges cover every other tenant on that cloud, as cloud IP ranges are not an allowlist explains. That leaves two real options.

  • Private networking. Run the code inside a network the database trusts. That means Lambda in the same VPC as ElastiCache, VPC peering on Redis Cloud Pro, or VPC peering or AWS PrivateLink on Upstash Pro. It only works when your code runs in a VPC you control.
  • A fixed egress IP. Put a NAT gateway in front of VPC-attached functions, or send the Redis connection through a proxy with static IPs. The proxy is the option for platforms with no VPC, such as Vercel, Netlify, and Railway.

Turn on the Redis Cloud CIDR allow list

  1. 1
    Open the databaseIn the Redis Cloud console, select Databases, pick the database, and select Edit database on its Configuration screen.
  2. 2
    Add your addressesIn the Security section, turn on the CIDR allow list toggle. Enter each address in CIDR form, such as 203.0.113.10/32, and select the check mark. Select Add CIDR for each further entry.
  3. 3
    SaveSelect Save database. From then on, only listed addresses can connect, and traffic from every other address is blocked.

The list also covers the private endpoint. Redis Cloud's allow list docs say that if you connect through VPC Peering or Transit Gateway, those addresses must be on the list too. If you turn the list on with only your proxy IPs, you cut off every peered client you forgot about. Collect all current clients before you save.

Turn on TLS while you are there

Redis Cloud does not enable TLS by default, and Free Essentials databases cannot use it at all (TLS docs). Without TLS, your password and every value cross the internet in plaintext. On paid plans, turn TLS on in the same Security section. You can also require client certificates (mutual TLS). Once TLS is on, the database refuses unencrypted connections. Existing connections keep their old mode until they reconnect.

Download redis_ca.pem from the console and give your client the whole bundle. It holds a public GlobalSign root plus Redis Cloud's own self-signed roots, which are deprecated but still in use. The system trust store alone may not verify your database's certificate.

Terminal
# Host and port are on the database's Configuration screen.
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls --cacert redis_ca.pem \
  --user default --askpass PING

The Upstash allowlist, TCP, and REST

The Upstash IP allowlist lives in the Configuration section of the database page. Each entry is one IPv4 address or a CIDR block. A connection is allowed when it matches any entry. Upstash notes that changes can take a few minutes to propagate, so wait before you decide a rule is wrong. TLS is always on for Upstash Redis.

An Upstash database has two front doors. The TCP endpoint speaks the Redis protocol to ioredis, redis-py, go-redis, and redis-cli. The REST API takes a command as a JSON array in a POST body with an Authorization: Bearer token, and the @upstash/redis SDK uses it. The allowlist page does not say whether the list filters REST requests as well as TCP. Test both before you rely on it, as the verification steps below show.

If you call the REST API from Node and want those calls to leave from a fixed IP, the SDK gets in the way. Version 1.41.0 of @upstash/redis calls the global fetch and has no proxy or dispatcher option. For the few commands that need a fixed IP, call the REST API with undici and a ProxyAgent.

upstash.ts
// npm install undici
import { fetch, ProxyAgent } from "undici";

const dispatcher = new ProxyAgent(process.env.PROXY_URL ?? "");

// Runs one Redis command through Upstash's REST API, from the proxy's IP.
export async function upstash<T>(...command: (string | number)[]): Promise<T> {
	const res = await fetch(process.env.UPSTASH_REDIS_REST_URL ?? "", {
		method: "POST",
		headers: { Authorization: `Bearer ${process.env.UPSTASH_REDIS_REST_TOKEN}` },
		body: JSON.stringify(command),
		dispatcher,
	});
	const body = (await res.json()) as { result?: T; error?: string };
	if (!res.ok || body.error) {
		throw new Error(body.error ?? `Upstash REST returned ${res.status}`);
	}
	return body.result as T;
}

// await upstash<string>("SET", "greeting", "hello");

Edge runtimes cannot send fetch through an HTTP CONNECT proxy at all. If your code runs on Vercel Edge or Cloudflare Workers, read edge runtimes and outbound proxies first.

ElastiCache uses security groups, not IP lists

Node-based ElastiCache clusters have no public IP. AWS's access guide says that even a security group rule for 0.0.0.0/0 does not expose such a cluster to the internet, because nothing outside the VPC can reach it. The real control is which security groups may reach port 6379.

If your code is a Lambda function, attach it to the VPC and allow the function's security group in the cache's security group. AWS's Lambda and ElastiCache tutorial does exactly that, and no fixed IP is involved. The cost moves elsewhere. Once the function is in the VPC, its calls to the internet need a NAT gateway, with the charges described in NAT gateway hidden costs.

From outside AWS, such as Vercel or Railway, the documented route is an EC2 NAT instance with iptables port forwarding. AWS limits that to testing and development. Traffic to the instance is unencrypted, the instance is a single point of failure, and it does not work with cluster mode enabled, because clients follow MOVED and ASK redirects to internal node addresses. For production, AWS points to Site-to-Site VPN or Client VPN.

Serverless caches with a public endpoint

ElastiCache Serverless for Valkey 9.0 and later can now be created with a public endpoint (--connection-type public) that clients reach directly over the internet. Every user in the cache's user group must authenticate with IAM. Per the IAM authentication docs, tokens are valid for 15 minutes, and AWS disconnects a connection after 12 hours unless the client sends AUTH or HELLO with a fresh token.

The same page lists the IAM condition keys ElastiCache supports. Serverless caches with a VPC endpoint get aws:VpcSourceIp, aws:SourceVpc, and aws:SourceVpce. Replication groups get aws:SourceIp. The page names no source-IP key for public-endpoint caches. As of November 2026, you cannot pin one of those caches to your fixed IP, so IAM is the gate. If your security team needs an address-based rule for ElastiCache, the cache has to stay private.

Send Redis connections through a fixed IP

Redis is a TCP protocol, not HTTP. A proxy you set for fetch does nothing for it. You need SOCKS5, which carries any TCP connection, or a local port forward. Redis TLS runs end to end inside the tunnel. The proxy sees the destination host and port and a stream of encrypted bytes.

Send the hostname to the proxy and let it resolve the name, which is what the socks5h scheme means. Managed Redis hostnames then resolve in the proxy's region, and your platform's resolver never sees them. The post on socks5 vs socks5h covers the difference. Both snippets below send the name.

Neither ioredis nor redis-py has a built-in SOCKS option. go-redis takes a custom Dialer. ioredis does accept a Connector class in its options. The option is typed and the AbstractConnector base class is exported, but the README documents neither, so pin your ioredis version and retest on upgrades. We ran both snippets against Redis 7.4 with TLS behind a local SOCKS5 server, using ioredis 6.0.0 with socks 2.8.10 and go-redis 9.23.0.

// npm install ioredis socks
import { once } from "node:events";
import tls from "node:tls";
import { AbstractConnector, Redis } from "ioredis";
import { SocksClient } from "socks";

const socks = new URL(process.env.SOCKS_PROXY_URL ?? "");
const target = new URL(process.env.REDIS_URL ?? ""); // rediss://default:PASSWORD@host:port

// Opens each Redis connection through SOCKS5, then runs TLS to Redis
// with the real host name, so SNI and certificate checks still work.
// It always uses TLS, so use a rediss:// URL.
class SocksConnector extends AbstractConnector {
	private tlsOptions: tls.ConnectionOptions;

	constructor(options: unknown) {
		// ioredis passes the client's own options, including tls.
		const opts = options as { disconnectTimeout?: number; tls?: tls.ConnectionOptions };
		super(opts.disconnectTimeout ?? 2000);
		this.tlsOptions = opts.tls ?? {};
	}

	async connect() {
		this.connecting = true;
		const { socket } = await SocksClient.createConnection({
			proxy: {
				host: socks.hostname,
				port: Number(socks.port),
				type: 5,
				userId: decodeURIComponent(socks.username),
				password: decodeURIComponent(socks.password),
			},
			command: "connect",
			destination: { host: target.hostname, port: Number(target.port) },
			timeout: 10_000,
		});
		const stream = tls.connect({
			...this.tlsOptions,
			socket,
			servername: target.hostname,
		});
		await once(stream, "secureConnect");
		this.stream = stream;
		return stream;
	}
}

// Module scope: warm invocations reuse this client.
export const redis = new Redis(target.toString(), {
	Connector: SocksConnector,
	// Redis Cloud: the contents of redis_ca.pem from the console.
	tls: process.env.REDIS_CA_PEM ? { ca: process.env.REDIS_CA_PEM } : {},
	maxRetriesPerRequest: 2,
});

Two details matter in both. First, start TLS yourself after the SOCKS handshake and give it the real hostname as the server name, so SNI and certificate checks pass. Second, pass Redis Cloud's CA bundle. ioredis hands its tls option to the connector, and redis.ParseURL in go-redis builds a TLS config for rediss:// URLs that you can extend.

For redis-py and other clients with no hook, run a port forward next to the app and point the client at 127.0.0.1. Pass the real hostname for SNI, as in redis-cli --tls --sni. That needs a long-lived process, so it fits Railway, Render, Fly.io, and VMs. A function cannot keep a background process alive between invocations.

Cluster mode needs every node reachable

A cluster-aware client learns node addresses from the server and follows MOVED and ASK redirects. That is the same reason AWS's NAT-instance method fails with cluster mode. A SOCKS dialer copes, because every node connection goes through the same dialer, as long as the announced addresses are reachable from the proxy. A single forwarded local port does not cope.

Connections, pools, and idle timeouts

  • Create the client at module scope, never inside the handler. Warm invocations reuse it, so each function instance holds one connection instead of one per request.
  • Every function instance is its own connection to Redis and through the proxy. A burst of concurrent instances becomes a burst of connections. Managed Redis plans cap connections, so check your plan's limit before a traffic spike finds it for you.
  • Proxies close idle connections. A function frozen between invocations can wake up holding a socket that is already closed. The first command fails and the client reconnects. Keep maxRetriesPerRequest low so a dead socket fails fast and does not eat the function's timeout.
  • Reconnects go through the connector again, so they leave from the same fixed IP. In our test, restarting Redis mid-run cost one reconnect and no failed commands.

The post on database connections through SOCKS5 goes deeper on pools, keepalives, and idle timeouts for Postgres and MySQL. The same rules apply to Redis.

Verify the list before you remove 0.0.0.0/0

  1. 1
    Add the fixed IPs next to the old entriesAdd each proxy IP as a /32. Leave the existing entries alone for now, so nothing breaks while you test.
  2. 2
    Confirm the egress addressSend one request through the proxy to an IP echo service and check that it prints one of the addresses you listed. Fixedmark's egress check shows how.
  3. 3
    Connect from a listed addressDeploy the connector code and run a PING. A PONG proves the path works end to end.
  4. 4
    Connect from an unlisted addressFrom your laptop, connect directly. Once you remove the broad entries, this should fail at the network or TLS level, not with a Redis error such as WRONGPASS. That tells an allowlist block apart from a bad password.
  5. 5
    Remove the broad entriesDelete 0.0.0.0/0, old office addresses, and anything with no clear owner. Then repeat the last two checks.
Terminal
# From an address that is not on the list. Expect a connection failure, not PONG.
redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" --tls --cacert redis_ca.pem \
  --user default --askpass PING

# Upstash only: does the list filter REST too? A JSON result means it does not.
curl -s -X POST "$UPSTASH_REDIS_REST_URL" \
  -H "Authorization: Bearer $UPSTASH_REDIS_REST_TOKEN" \
  -d '["PING"]'
An allow list is a second factor, not a replacement for credentials. Keep a strong password or ACL user per app, scope it to the commands and keys it needs, and rotate it. The list makes a leaked secret much less useful on its own.

Doing this with Fixedmark

Fixedmark, in early access, gives an app a pair of static IPv4 addresses with a SOCKS5 endpoint. Pro and higher plans get a dedicated pair. Starter and the trial share theirs with other customers, so use a dedicated pair when the allow list is your security control. The pair is two allow list entries, which fits even a Redis Cloud plan with only four. Put the SOCKS URL from the dashboard, such as socks5h://APP_ID:TOKEN@mum.egress.fixedmark.com:1080, in SOCKS_PROXY_URL, and the connector code above works unchanged. The databases guide has the go-redis version.

Port 1080 is plain SOCKS5, so the proxy credentials cross the network unencrypted. Redis TLS inside the tunnel stays encrypted end to end. For hosts that keep a process running, fm tunnel forwards a local port to Redis over SOCKS5 inside TLS on port 1443, so any client works, including redis-py.

  • On plans with destination allowlists, add a rule for the Redis host and port. A leaked token can then reach that database and nothing else.
  • Connection logs show the destination, SNI, bytes, egress IP, and result of each connection, which makes a blocked allow list easy to spot.
  • Use the database's public endpoint. Fixedmark blocks private and reserved address ranges.
  • Idle connections close after 5 minutes by default, per the limits page. Let the client reconnect, as shown above.
  • Pick the region closest to your database. Planned launch prices are on the pricing page.

Sources

Checked November 2026. Confirm current details on the vendor's site before you decide. Prices and limits change.

Blog

Frequently asked questions

Does the Redis Cloud free plan support a CIDR allow list?

No. The CIDR allow list needs paid Redis Cloud Essentials or Redis Cloud Pro. The free plan cannot use TLS either, so its databases accept plaintext connections from any address.

Can I allowlist Vercel or Lambda IPs in Upstash?

Not reliably. Upstash's own docs say you cannot know the IP addresses of serverless platforms such as AWS Lambda and Vercel functions. Send the connection through a fixed IP, or put a Lambda function in a VPC with a NAT gateway.

Does Redis TLS still work through a SOCKS5 proxy?

Yes. SOCKS5 carries raw TCP, so the client and Redis negotiate TLS end to end. Start TLS after the SOCKS handshake and pass the real hostname as the server name so certificate checks pass.

Can I restrict an ElastiCache Serverless public endpoint to one IP?

Not as of November 2026. AWS's IAM authentication docs list source-IP condition keys for replication groups and for VPC-endpoint serverless caches, and none for public-endpoint caches. IAM authentication is the control there.

Does the Upstash allowlist accept IPv6 addresses?

No. Upstash says the IP allowlist currently supports IPv4 addresses only. Make sure your proxy or NAT leaves over IPv4.

Make it fixed.

Fixedmark is in early access. Join the list to get dedicated static IPs when your region opens.