DigitalOcean Droplet 502 Bad Gateway (Nginx)

Share
Ongoing Linux Updated November 13, 2026Based on 3 user reportsHow we research

Quick answer

A 502 on a Droplet almost always means Nginx is running but the app behind it (Node, PHP-FPM, Gunicorn) is down, crashed or on a different port or socket. Check the upstream service and Nginx error log.

Most likely fix: Read the Nginx error log

How to fix it

Try these in order — the most common fix is first.

  1. 1. Read the Nginx error log

    1. SSH in and run sudo tail -n 50 /var/log/nginx/error.log
    2. Look for "connect() failed (111: Connection refused) while connecting to upstream" (app is down) or "No such file or directory" (socket path wrong)
    Did this fix it?
  2. 2. Restart and verify the upstream app

    1. Check it runs: systemctl status your-app (or php-fpm, gunicorn, pm2 status)
    2. Confirm the port with sudo ss -plnt and compare with proxy_pass in your Nginx site config
    3. Restart the app, then sudo nginx -t && sudo systemctl reload nginx
    Did this fix it?
  3. 3. Check memory

    1. Run free -h and sudo dmesg | grep -i "killed process"
    2. If the OOM killer ended your app, add swap or resize the Droplet (see the out of memory guide)
    Did this fix it?
  4. 4. If behind a DigitalOcean Load Balancer

    1. Open Networking > Load Balancers and check the health check path, port and protocol
    2. Make sure the Droplet firewall allows traffic from the load balancer
    Did this fix it?

Symptoms

Browser shows 502 Bad Gateway from nginx while the Droplet itself is up and SSH works.

Why it happens

  • App process crashed or was killed because the Droplet ran out of memory
  • Nginx proxy_pass points to the wrong port or socket
  • PHP-FPM or Gunicorn socket path or permissions changed after an update
  • Upstream is overloaded and times out
  • Load balancer health checks fail so it has no healthy backend

This guide also covers

  • digitalocean 502 bad gateway
  • droplet nginx 502 bad gateway
  • digitalocean 502 error
  • nginx bad gateway digitalocean

Still not working?

If DigitalOcean keeps failing, you're not alone. See every DigitalOcean problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

Other DigitalOcean errors

All 10 DigitalOcean errors and fixes →