nginx: 1024 worker_connections are not enough
Each worker has a fixed number of connection slots and a proxied request uses two of them, one to the client and one to the upstream, so the ceiling arrives at roughly half the concurrency you expected. New connections queue or fail while CPU and memory look fine, and the message repeats once per worker in the error log.
Quick fix
Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.
# Measure the ceiling rather than guessing at it
curl -s localhost/nginx_status # requires stub_status
ss -tan state established | wc -l
# events block, not http: proxied requests take two slots each
events {
worker_connections 8192;
}
worker_processes auto;
worker_rlimit_nofile 32768; # must exceed worker_connections
# The file descriptor limit is the real cap, and systemd sets its own
systemctl show nginx -p LimitNOFILE
# override with a drop in: [Service] LimitNOFILE=65535
sudo nginx -t && sudo systemctl reload nginx
# Keepalive to upstreams removes most of the second slot's churn
# upstream app { server 127.0.0.1:3000; keepalive 64; }
How to diagnose WebServer errors
Web server errors are usually about permissions, binding, or configuration that was never loaded. A common trap: the server runs as an unprivileged user (www-data, nginx), so it needs execute permission on every directory in the path to a file, not just read permission on the file itself. Another: editing a config file changes nothing until the server is reloaded and the file is actually included.
If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.
- Validate configuration before reloading:
nginx -t,apachectl configtest,caddy validate. This catches syntax errors without dropping traffic. - Dump the fully resolved configuration with
nginx -Tto see what is actually in effect, including every include. - Read the error log, not the access log, for 5xx causes. nginx names the failing upstream and the exact filesystem path it could not open.
- For permission errors, test as the server user:
sudo -u www-data cat /path/to/file. Check execute bits on every parent directory. - For binding failures, find the current listener with
ss -tulpn | grep :80. Ports below 1024 need privileges or a capability such asCAP_NET_BIND_SERVICE.
Tools worth reaching for
nginx -t / nginx -Tapachectl configtestss -tulpntail -f error.logsudo -u www-data
Authoritative references
Primary documentation for this error, worth reading before applying any fix in production.
Related WebServer errors
- Apache: .htaccess: Option Indexes not allowedDirectory listing (Options Indexes) is disabled in main config but requested in .htaccess.
- Apache: AH00161: server reached MaxRequestWorkers setting, consider raisingEvery Apache worker is busy, so new connections wait in the listen queue and the site slows…
- Apache: AH00558: Could not reliably determine the server's FQDNServerName is not set, so Apache guessed from the system hostname. It is a warning and the…
- Apache: AH01071: Got error 'Primary script unknown'The message is PHP-FPM's, relayed by Apache: the script path Apache sent over FastCGI does…
- Apache: AH01630: client denied by server configurationmod_authz_core decided the request was not allowed for that directory, so it never reached…
- Apache: Invalid command 'Order', perhaps misspelled or defined by a moduleOrder, Allow and Deny moved into mod_access_compat in 2.4, so configuration written for 2.2…
- Apache: mod_rewrite not enabledURL rewriting rules in .htaccess are not working because the mod_rewrite module is not loaded…
- Caddy: 502 Bad Gateway (reverse proxy)Caddy's reverse proxy cannot reach the upstream backend. The backend service may be down or…
Browse other categories
- HTTP 494xx client errors, 5xx server errors, redirects, headers and protocol problems.
- JavaScript 42npm resolution, async pitfalls, hydration, memory limits and runtime type…
- Database 41Connections, deadlocks, constraints, replication and memory limits.
- AI 35Rate limits, context windows, GPU memory and model-serving failures.
- Network 35Refused connections, timeouts, resets, MTU problems and port exhaustion.
- Python 35Imports, virtual environments, encoding, concurrency and dependency conflicts.
- Kubernetes 34CrashLoopBackOff, ImagePullBackOff, OOMKilled, RBAC, scheduling and storage.
- Docker 27Daemon connectivity, disk space, image pulls, ports and architecture mismatches.
- System 26Disk space, systemd units, file descriptors, OOM killer and scheduled jobs.
- Cloud 25IAM permissions, quotas, service limits and credential failures.
- Security 25JWT validation, CSRF, OAuth grants, SELinux, SSH host keys and CSP.
- TLS 24Untrusted authorities, expiry, hostname mismatch, chains and cipher negotiation.
Something missing or wrong?
This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.