How can i fix a 502 bad gateway?

Hello everybody !
I have a big problem !!

After a Linode restore, the web server is down

i'm getting a "502 bad gateway" response

I tried to restart nginx but it can't find it..!

Any suggestions how to fix the problem?

Thank you in advance.

3 Replies

Hey there,

There are a number of commands that we can run to determine if a Linode’s networking interfaces are brought up properly after a reboot.

cat /etc/network/interfaces
systemctl status networking.service
ip a
ip r

If you aren't having any additional networking issues, you can locate all of your Nginx related files and directories with the following to determine if it's still present on the system following your restore:

find -L . -name '*nginx*'
sudo find / -type d -name 'nginx'

Thhis will produce a lot of output if nginx is present. You don't need to parse through all of the files. If Nginx is still present, I'd recommend running the following troubleshooting commands from your Linode's terminal (or the Lish console):

To check the status of Nginx:

systemctl status nginx

To check which services are listening on which ports:

netstat -plunt

If Nginx isn't running, or if another service is listening on port 80, you'll need to kill off that process (assuming it's one you don't need) and start Nginx in its place:

systemctl start nginx

Here is another Community Post that addresses troubleshooting Nginx.

We've seen other customers have issues serving websites when they have both apache and Nginx installed and misconfigured. You can check for apache on your system with the following:

systemctl status apache2.service

If Nginx is not on the system at all, you may need to reinstall.

We hope that helps. Let us know if it moved your troubleshooting forward towards a resolution.

Tara T
Linode Support Team

One likely cause of this problem (particularly after an in-place OS upgrade) is that your site is configured to have nginx use a socket path which was appropriate for the version of PHP in place before the upgrade and which needs to be adjusted to match the new version of PHP. If this is the cause of the message, make the adjustment, restart nginx, and you should be back on the road.

The problem was solved on my debian 9 > 10 upgrade with:

systemctl stop php5-fpm
see here: /etc/php/8.2/fpm/pool.d/www.conf
look for the: listen = /run/php/php-fpm.sock
fix to this: listen =
sudo systemctl enable php8.2-fpm
sudo systemctl start php8.2-fpm
sudo systemctl stop nginx
sudo systemctl start nginx


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct