Nginx: [error] connect() failed (111: Connection refused) while connecting to upstream, upstream: "http://127.0.0.1:3000/"
Nginx tried to proxy a request but nothing listens on the upstream address, so the client gets 502.
[error] connect() failed (111: Connection refused) while connecting to upstream, upstream: "http://127.0.0.1:3000/"502 Bad Gateway connect() failed (111 proxy_pass upstreamnginx proxy_pass upstream http connection refused 502 Meaning
The backend (Node, Gunicorn, PHP-FPM TCP port) isn't running, listens on a different port/interface, or crashed. Start it, verify with ss -ltnp | grep 3000 and curl 127.0.0.1:3000. In Docker use the service name (not localhost) and ensure the container is healthy.
Common causes
- Backend not running or crashed
- Wrong port/host in
proxy_pass - Backend bound to a different interface (IPv6 vs IPv4)
- Docker networking (localhost)
- Startup race after deploy
⚡ Quick fix
- Start the backend service and check its logs
- Match
proxy_pass http://127.0.0.1:PORT;to the listener - In Docker/K8s use the service name
Detailed fix by platform
Linux
ss -ltnp | grep :3000; curl -I http://127.0.0.1:3000/
How to diagnose
- Listener — Port open?
- proxy_pass — Matches?
- Docker — Service name?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 502 HTTP 502 Bad Gateway
- AH00898: Error reading from remote server (502 Proxy Error) Apache: [proxy_http:error] AH01102: error reading status line from remote server 127.0.0.1:3000 / AH00898: Error reading from remote server returned by /api
- AH01114: HTTP: failed to make connection to backend Apache: [proxy:error] AH00957: HTTP: attempt to connect to 127.0.0.1:3000 (127.0.0.1) failed / AH01114: HTTP: failed to make connection to backend: 127.0.0.1
Most viewed in Nginx / Apache
- nginx: [emerg] unknown directive Nginx: nginx: [emerg] unknown directive "x" in /etc/nginx/sites-enabled/x:12 — configuration file test failed
- upstream timed out Nginx: upstream timed out (110: Connection timed out) while reading response header from upstream
- AH00558 Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name
Other ways to find it
Where this error sits
Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026