Report this

What is the reason for this report?

Nginx returns <b>502 Bad Gateway</b> after upgrading to Ubuntu 24.04

Posted on July 10, 2026
Ruz

By Ruz

I recently upgraded my DigitalOcean droplet from Ubuntu 22.04 to Ubuntu 24.04 LTS. After the upgrade, nginx started returning 502 Bad Gateway errors for all my sites.

I have checked the following so far:

  • nginx service is running fine (systemctl status nginx shows active)
  • PHP-FPM 8.3 is running and listening on the correct socket
  • The upstream Node.js app responds correctly when I curl localhost:3000 directly
  • No permission issues on socket files

Here is the relevant error from /var/log/nginx/error.log:

connect() failed (111: Connection refused) while connecting to upstream

My nginx config uses proxy_pass to forward requests to a Node.js application running on port 3000. The app works fine when accessed directly but nginx cannot proxy to it.

I suspect something changed with systemd socket activation or AppArmor profiles in Ubuntu 24.04 Noble Numbat. Has anyone else experienced this issue after upgrading?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

the connect() failed (111: Connection refused) while connecting to upstream error almost always means an issue with the app behind the reverse proxy. Check the error logs of the app. It can be a broken function or something.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.