Redis TLS clients hang at connection 1024, and plain TCP never notices
Redis 8.0 to 8.12.0 with TLS can leave a client stuck in the handshake once the server passes 1024 connections. Fixed in 8.12.1, 8.10.4 and four more.
By Meet ModiThe bug that Redis shipped six patch releases for on December 4 only bites one client out of roughly a thousand, and only if that client speaks TLS. Plain TCP clients on the same server, at the same moment, are fine. If you run Redis TLS on any 8.x release up to 8.12.0 and your server holds more than 1024 connections, a few clients can sit in the TLS handshake forever. The fix is a three-line change to which number an array index gets checked against.
So, short answer for anyone searching "redis tls" because a connection just hung: if `INFO server` says 8.0.0 to 8.12.0, TLS is on, and you have been near or past a thousand clients, upgrade to the patch release on your line. That is 8.2.12, 8.4.9, 8.6.9, 8.8.5, 8.10.4 or 8.12.1. Redis 7.x and Valkey do not have this bug, and 8.0.x is affected with no fix coming.
What Redis shipped on December 4
Six releases went out in 18 minutes, each opening with "Update urgency: HIGH: There are critical bugs that may affect a subset of users." 8.12.1 carries exactly one fix. Its whole changelog is one line: "With TLS enabled, clients could hang in the TLS handshake (and stay in CLIENT LIST) once the server had more than 1024 connections, due to an out-of-bounds read in the event loop." The 8.10.4 and 8.8.5 releases also fix a listpack encoding mismatch and a ZRANGESTORE use-after-free, which are separate stories.
- Dec 23, 2024Async IO Threads (#13695) is merged into unstable. Per the later fix, this is when the event loop started at 1024 entries and grew on demand.
- May 2, 2025Redis 8.0.0 is released with that event loop. Every 8.x line since inherits it.
- Nov 20, 2026GitHub user pymonger opens PR #16307 after hitting the hang on 8.6.2 and 8.6.8 in production: "once a server crossed 1024 connections, a few clients blocked forever."
- Nov 26, 2026Two Redis maintainers approve it and it is merged into unstable.
- Dec 4, 2026, 15:36 to 15:54 UTC8.2.12, 8.4.9, 8.6.9, 8.8.5, 8.10.4 and 8.12.1 are published with the fix.
- Dec 5, 2026Docker Hub has all six as tags of the official redis image.
What the releases do not have: a CVE, an advisory, a severity score, or a word about Redis Cloud and other managed offerings. It is filed as a bug, not a vulnerability. That is a fair call for a hang, though the PR also notes that the delete path can write to the out-of-bounds slot, and nobody says what that write could do.
Why only Redis TLS connections hang
Redis keeps one array of file events per event loop, indexed by file descriptor number. Before 8.0 it allocated that array at full size: maxclients plus 128 slots. Since the async I/O rework, it starts at 1024 entries and doubles when someone registers an fd beyond the end. That growth happens in exactly one place, aeCreateFileEvent().
Three other functions, aeGetFileEvents(), aeGetFileClientData() and aeDeleteFileEvent(), kept the old bounds check. They compared the fd against setsize, the maximum the array may ever grow to, instead of nevents, its size right now. For an fd between those two numbers, they read memory past the end of the array.
int aeGetFileEvents(aeEventLoop *eventLoop, int fd) {
- if (fd >= eventLoop->setsize) return 0;
+ if (fd >= eventLoop->nevents) return 0;
aeFileEvent *fe = &eventLoop->events[fd];
return fe->mask;Plain TCP never asks. The socket code registers its read handler straight away, which goes through aeCreateFileEvent() and grows the array first. The TLS code is more polite. updateSSLEvent() and registerSSLEvent() in tls.c both start by asking "what am I already registered for?" so they only add what is missing. For a brand new fd past the end of the array, that question reads garbage.
If the garbage happens to have the readable bit set, TLS concludes it is already listening for reads and skips the registration. Nobody ever reads from that socket. The client sends its ClientHello and waits for an answer that will not come. The array does not grow either, because nothing called the function that grows it, so the next new fd is in the same position.
Why connection 1024, 2048 and 4096
The array starts at 1024 entries, so the first fd that falls off the end is 1024. Once a plain TCP client or any other registration lands past it, the array doubles to 2048 and the cliff moves. In the reporter's run of 4300 TLS connections, the stuck clients sat at fd=1024 and fd=4096, two or three per run, three runs out of three.
The size of the window comes from maxclients, which defaults to 10000. Redis sizes the event loop at maxclients plus 128, so with the default every fd from 1024 to 10127 is inside the allowed range but can be outside the allocated array. If maxclients is 896 or lower, the loop is 1024 or smaller, both numbers are equal, and the old check was enough. Each I/O thread has its own event loop and its own array, so with io-threads on, each thread can hit its own cliff.
Whether a given out-of-bounds read hangs a client depends on whatever sits in memory after the array. That is why the reporter saw two or three stuck clients out of 4300, not all of them, and why it reproduced reliably for them only when the server loaded the default redis.conf. Under AddressSanitizer it fails every time: a 4-byte read "located 0 bytes after 32768-byte region". That region is 1024 entries of 32 bytes: the starting array, exactly.
Which Redis versions are affected
I did not run Redis for this post. I tried to build 8.12.0 and 8.12.1 with TLS and replay the reporter's 4300-connection test, and the sandbox this was written in refused the build. So everything below comes from reading source, not from a server. I checked the guard in aeGetFileEvents() in every release around the fix, straight from the tagged source:
tag lazy array guard in aeGetFileEvents()
7.4.12 no fd >= setsize (array is full size, safe)
8.0.0 yes fd >= setsize affected
8.0.6 yes fd >= setsize affected, no fix planned
8.2.11 yes fd >= setsize affected
8.2.12 yes fd >= nevents fixed
8.4.8 yes fd >= setsize affected
8.4.9 yes fd >= nevents fixed
8.6.8 yes fd >= setsize affected
8.6.9 yes fd >= nevents fixed
8.8.4 yes fd >= setsize affected
8.8.5 yes fd >= nevents fixed
8.10.3 yes fd >= setsize affected
8.10.4 yes fd >= nevents fixed
8.12.0 yes fd >= setsize affected
8.12.1 yes fd >= nevents fixed
valkey 8.1.4 / 9.2.1 allocates setsize up front, safeA diff of the 8.12.0 and 8.12.1 source tarballs touches four files: the release notes, version.h, server.c (which only registers the new unit test) and ae.c. If you have been putting off a patch upgrade because you are not sure what else changed, nothing else changed.
One detail makes the affected group bigger than "people who compiled Redis with TLS". The official Docker image builds with BUILD_TLS=yes, per line 186 of its Dockerfile template, so every redis:8 container has the TLS code in it. It only matters once you set tls-port. One detail makes it smaller: Valkey, the fork, forked from 7.2 before the async I/O rework, so its ae.c still allocates the full array up front.
How to spot a stuck TLS client in Redis CLIENT LIST
The stuck connection is a real client object as far as Redis is concerned. It counts in connected_clients, it uses a slot under maxclients, and because its fd is never polled, Redis never learns the peer hung up. The reporter's CLIENT LIST lines looked like this:
id=1011 fd=1024 age=16 cmd=NULL tot-net-in=0 tot-cmds=0
id=4083 fd=4096 age=4 cmd=NULL tot-net-in=0 tot-cmds=0So the filter is: cmd=NULL, tot-net-in=0, an age that keeps climbing, and an fd at or a little past a power of two from 1024 up. A healthy client that just connected also has cmd=NULL for a moment, which is why age matters. Something like this will list them, though I could not run it against an affected server here:
redis-cli --tls -p 6379 CLIENT LIST \
| grep 'cmd=NULL' | grep 'tot-net-in=0 ' \
| awk '{ for (i=1;i<=NF;i++) if ($i ~ /^(id|fd|age)=/) printf "%s ", $i; print "" }'One field that looks useful and is not: events. In CLIENT LIST it comes from whether the connection object has a read handler set, not from the event loop. The stuck client does have a handler set; it is the event loop that never heard about it. So a stuck client can still show events=r.
Redis connection timeout errors are the likelier symptom
"Blocked forever" assumes the client waits forever, and current client libraries mostly do not. I read the defaults rather than trusting memory. redis-py 8.2.0 sets the connect timeout to 5 seconds and applies it to the TLS wrap. ioredis 6.1.1 has connectTimeout at 10,000 ms and waits for secureConnect when TLS is on. node-redis defaults to 5,000 ms. All three time out the handshake and retry.
So the likely picture on a busy server is not a frozen app. It is a connect timeout every so often under load, a retry that works, and a connected_clients number that creeps up and never comes back down, because each abandoned handshake leaves a stuck entry behind. If you have ever chased a race that only shows up under load, this has the same smell: it passes every test with ten connections.
That creep is how it could turn into a "redis too many connections" error at the worst time. Each stuck entry holds an fd and a maxclients slot until the process restarts, and a restart makes it look fixed. Nothing I read gives a rate, so I can't say whether that takes days or years on a real workload.
What to do about it
- Check the version with INFO server. If redis_version is 8.0.0 to 8.12.0 and tls-port is not 0, you are in the window.
- Upgrade within your line: 8.2.12, 8.4.9, 8.6.9, 8.8.5, 8.10.4 or 8.12.1. For 8.12 the diff is the fix plus a test, which is about as small as an upgrade gets.
- On 8.0.x, move to 8.2.12 or later. The project's SECURITY.md lists 8.0.x as unsupported, and no 8.0 release has the fix.
- Until you can upgrade, look at the timeout setting. It defaults to 0, meaning never. Reading timeout.c, a nonzero value should close an idle client that is not a replica, not blocked and not subscribed, and a stuck handshake is idle from birth. I have not tested this, and I did not check whether it covers clients owned by I/O threads.
- If Redis sits behind a job queue, like the BullMQ setup in this post on queueing emails, watch connected_clients. More on that below.
Queue workers hold long-lived connections and usually reconnect with backoff, so they hide this well: a worker that times out once, reconnects and carries on looks healthy. The number to watch is connected_clients drifting above the number of processes you actually run.
The catch: 8.0 gets no fix and the stopgaps are guesses
Three things I would not paper over. First, 8.0.x has the bug and is out of support, so anyone who upgraded to 8.0 when it came out and stopped there is on an affected release with no patch on their line. That is a minor version jump, not a patch, and it deserves a test run.
Second, the only workarounds short of upgrading are mine, from reading source. Lowering maxclients to 896 or below makes the old bounds check correct, but it also caps you below the point where you hit the bug, which for most people is a cure worse than the disease. The timeout setting looks right on paper and is untested. Neither is a reason to delay the patch.
Third, nobody has said how far this goes. One person reported it, on 8.6. There is no statement on Redis Cloud or on providers that run Redis 8 for you, and no CVE to search for, so a scanner that keys on CVEs will not flag it. If someone else runs your Redis, ask them which version they are on.
Which Redis versions fix the TLS connection hang?
Redis 8.2.12, 8.4.9, 8.6.9, 8.8.5, 8.10.4 and 8.12.1, all released on December 4, 2026, fix it. Each one changes the bounds check in three event loop functions from setsize to nevents. Every 8.x release before those, from 8.0.0 on, has the bug. Redis 8.0.x is out of support and has no fixed release, so move to 8.2.12 or later.
What is the default maxclients in Redis?
The default maxclients in Redis is 10000. Redis sizes each event loop at maxclients plus 128, so the default gives 10128 slots. Since 8.0 only the first 1024 are allocated at start and the rest are added as needed, which is the gap this TLS bug fell into. Redis can lower maxclients at startup if the process's open file limit is too small.
Is Redis 7 affected by the TLS 1024 connection bug?
No. Redis 7.4.12 and earlier allocate the whole event array at startup, so the old bounds check is correct and there is nothing past the end to read. The lazy array arrived with the async I/O thread rework that shipped in Redis 8.0.0. If you are on 7.x and planning the jump to 8, go straight to a fixed release.
Does Valkey have the Redis TLS hang bug?
No. Valkey forked from Redis 7.2, before the change that made the event array grow lazily. Its aeCreateEventLoop() in 8.1.4 and 9.2.1 still allocates room for every file descriptor up to setsize at startup, so checking an fd against setsize is correct there. The Redis fix does not need porting to Valkey.
How do I enable TLS in Redis?
Start redis-server with tls-port set to a port number, plus tls-cert-file, tls-key-file and tls-ca-cert-file pointing at your certificate, key and CA. Setting port to 0 turns off plain TCP. Set tls-auth-clients to no if clients do not present certificates. Redis must be built with TLS; the official Docker image is. On 8.x, use a fixed release first.
Why does my Redis TLS connection time out under load?
On Redis 8.0.0 to 8.12.0, one cause is this bug. Past 1024 connections the server can skip registering a new TLS client for reads, so the handshake never finishes and your client's connect timeout fires. redis-py and node-redis give up after 5 seconds, ioredis after 10, then retry. Check the server version and look for stuck CLIENT LIST entries.
How do I find stuck clients in Redis CLIENT LIST?
Look for entries with cmd=NULL, tot-net-in=0 and an age that keeps growing. For this TLS bug, the fd will be at or just past 1024, 2048 or 4096. A fresh client also shows cmd=NULL briefly, so judge by age. The events field is not reliable here, because it reports the connection's handler, not the event loop.
- Fix TLS client hang when the fd exceeds the allocated ae events array (#16307), redis/redis on GitHub
- Redis 8.12.1 release notes, Redis
- Redis 8.10.4 release notes, Redis
- Redis 8.2.12 release notes, Redis
- Async IO Threads (#13695), redis/redis on GitHub
- Security Policy, supported versions, Redis
- src/tls.c at 8.12.0, redis/redis on GitHub
- src/ae.c in Valkey, valkey-io/valkey on GitHub
- Dockerfile.template for the official redis image, docker-library on GitHub
- redis/_defaults.py, redis-py on GitHub
More Posts
Chrome is about to distrust the CA that signs google.com
Chrome stops trusting ECDSA P-256 CA keys on March 15, 2027. Google Trust Services WE1 and WE2 are P-256, and 146 of 770 top sites I scanned chain to one.
My firewall allowed port 53. The packet landed on 9999
CVE-2026-139281 lets IPv6 fragments past an nftables firewall that uses conntrack. I reproduced it on Ubuntu's 7.0 kernel and tested two rules that stop it.
Laravel Go is a quarter slower than Laravel Rust. It rebuilds 35 times faster
Laravel Go served 1,318 req/s to Laravel Rust's 1,724 on one core in my rerun, then rebuilt in 2.9 s to Rust's 1 min 42 s. Here is the trade.