Your backend server hit its maximum connection limit and is refusing new requests. Here's what it means and exactly how to fix it — whether you're running Varnish, Nginx, or another proxy.
Ordered from fastest relief to long-term resolution.
| # | Action | Component | Impact |
|---|---|---|---|
| 1 | Increase max_connections in Varnish backend config | Varnish VCL | Immediate relief |
| 2 | Increase Nginx worker_processes and worker_connections | Nginx | Immediate relief |
| 3 | Enable Varnish's grace period to serve stale cache | Varnish VCL | Reduces 503 visibility |
| 4 | Add database connection pooling (PgBouncer etc.) | DB Layer | Root cause fix |
| 5 | Scale horizontally — add backend server nodes | Infrastructure | Long-term |
This error originates from Varnish Cache. When Varnish routes a request to a backend (your web server, app server, or API), it checks if the backend has capacity. Each Varnish backend has a max_connections parameter. When all connection slots are occupied, Varnish rejects the incoming request with a 503 Service Unavailable and the message "backend.max_conn reached."
Nginx, HAProxy, and other reverse proxies have analogous limits under different names. The root cause is almost always either too many concurrent users, slow backend responses causing connections to pile up, or the limit being set too low for actual traffic volume.
Edit your Varnish VCL file and increase the max_connections value on your backend definition:
Reload with: service varnish reload
Grace mode lets Varnish serve stale cached content while the backend is overloaded, preventing users from seeing 503 errors:
In /etc/nginx/nginx.conf:
Test and reload: nginx -t && systemctl reload nginx
Connection slots often pile up because backend requests are slow. Check for slow database queries, unoptimised PHP processes, or third-party API calls holding connections open.
It depends on your backend's capacity. A safe starting point is max_connections = (worker_threads × 0.8). Monitor with varnishstat and adjust based on real traffic.
Not always. Memory leaks, database deadlocks, or third-party API timeouts can cause backend threads to hang, consuming connection slots even under normal traffic.
A CDN reduces origin traffic by serving cached assets at the edge, which can significantly reduce backend connection pressure during traffic spikes.