2026/11/23 14:02:51 [alert] 1234#1234: *90817 768 worker_connections are not enough while connecting to upstream, client: 203.0.113.7, server: example.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "example.com"
The number in front (768 here) is your current worker_connections value. When a worker reaches it, new connections are refused or fail, and visitors see errors or hanging pages, usually in a traffic spike.
Quick fix: raise the limit in the events block, raise the file descriptor limit to match, and reload:
# /etc/nginx/nginx.conf
worker_processes auto;
worker_rlimit_nofile 16384;
events {
worker_connections 4096;
}
sudo nginx -t && sudo systemctl reload nginx
Keep worker_rlimit_nofile at least twice worker_connections (section 3), or you will trade this error for a "Too many open files" one.
1. How the limit works
worker_connections is the maximum number of connections each worker process can have open at the same time. The total is worker_processes × worker_connections.
Two things surprise people:
- It counts every connection, not just visitors. When Nginx acts as a reverse proxy, one visitor request uses at least two connections: one from the visitor and one to your backend. So 768 connections is about 380 simultaneous proxied requests per worker, not 768.
- Keep-alive and slow clients hold connections open. A visitor on a slow mobile network, or an idle keep-alive connection, still occupies a slot.
The default in the stock config is 512 in Nginx itself (and 768 in the Debian and Ubuntu packages), which is low for a busy proxy.
2. See how close you are
Count open connections for Nginx right now:
ss -s
sudo ss -tanp | grep nginx | wc -l
If you have stub_status enabled, it reports the numbers directly:
location = /nginx_status {
stub_status;
allow 127.0.0.1;
deny all;
}
curl -s http://127.0.0.1/nginx_status
"Active connections" near worker_processes × worker_connections confirms the limit is being hit. Check the error log for when it started:
sudo grep "worker_connections are not enough" /var/log/nginx/error.log | tail
3. Raise it safely
Each connection also uses one file descriptor, and a proxied request needs two. The worker's file descriptor limit has to be higher than the connection limit:
worker_rlimit_nofile 16384; # at least 2 x worker_connections
events {
worker_connections 4096;
}
worker_rlimit_nofile sets the limit for the worker processes, so you don't need to edit the systemd unit for it. Check that it took effect after a reload:
for p in $(pgrep -f "nginx: worker"); do grep "open files" /proc/$p/limits; done
If you instead see this in the log, the file descriptor limit is the next wall:
socket() failed (24: Too many open files) while connecting to upstream
accept4() failed (24: Too many open files)
Raising the value costs memory (a few KB per connection), so don't set it absurdly high "just in case". Pick it based on the numbers from section 2, with headroom.
4. When more connections are not the answer
If the count keeps climbing back to the limit no matter how high you set it, something is holding connections open:
- A slow or stuck backend. Requests wait for the app, each one holding two connections. Fixing the backend frees the slots: see the 110 timed out guide and the prematurely closed connection guide.
- Long keep-alive timeouts.
keepalive_timeout 65;is the default. Lowering it (for example 15 seconds) frees idle connections sooner on a busy server. - WebSockets and streaming. Each open WebSocket holds a connection for as long as it lives. A site with thousands of live sockets needs a much higher limit by design: see Nginx WebSockets reverse proxy.
- A traffic flood or bots. Check the access log for a single IP or user agent opening thousands of connections, and limit it with
limit_conn. - Upstream keep-alive pools. If you use
keepalivein anupstreamblock, each idle pooled connection counts too.
# limit each IP to 20 simultaneous connections
limit_conn_zone $binary_remote_addr zone=perip:10m;
server {
limit_conn perip 20;
}
5. Errors that look similar
| Log message | Meaning |
|---|---|
worker_connections are not enough | The per-worker connection limit was reached (this page) |
Too many open files (error 24) | The file descriptor limit was reached |
upstream timed out (110) | Backend too slow: guide |
no live upstreams | Every backend was marked failed: guide |
6. Know when it happens
This error appears in spikes, often at the busiest hour, and it is logged at alert level, which many people never read. The first sign is usually slow pages or 502 errors.
With Pingzo, an HTTP monitor calls your URL every 1 to 15 minutes depending on your plan, records the status code and response time, and opens an incident when 3 of the last 5 checks fail. Alerts go to WhatsApp, Slack, Telegram, Discord or email. A rising response time on the same monitor can show you the server filling up before it starts failing. See how to monitor an Nginx web server.
Related guides
- Fix: nginx no live upstreams while connecting to upstream
- Fix: nginx connect() failed (111: Connection refused) while connecting to upstream
- Linux server resource and saturation monitoring
Stop Finding Out About Outages from Angry Users
Get instant WhatsApp & Discord alerts the second your API, website, or server goes down. Setup in 30 seconds, with checks as often as every minute.