This is a pretty technical post. If most of the words in the title above are gibberish to you, this article likely isn’t for you. You’ll probably like the other things I’ve written more 😄 )


In the spirit of showing my work, here’s a quick fix to an annoying little upgrade bug I encountered when upgrading a server from version Debian 10 to Debian 11. Immediately after upgrading, the WordPress site that I was hosting (Specifically, the nginx server software WordPress was installed on) started giving a 502 Bad Gateway error:

502 Bad Gateway Error ☝🏼 Annoying. 🤔

Here’s how I solved it:

Check the logs!

So, nginx was throwing the error. That’s helpful.

I ran this command on the server:

tail -f -n 5 /var/log/nginx/error.log

That shows the last 5 lines of the nginx error log, as well as any new errors in real-time.

That spat out a bunch of errors like this:

2022/11/07 12:17:27 [crit] 1213#1213: *54 connect() to unix:/var/run/php/php7.3-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 108.111.108.122, server: example.com, request: "POST /wp-login.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "example.com"

Hmm… k…

So, as noisy and unhelpful as that looks, there’s actually a great hint in there: php7.3!

Debian 10 used php7.3, but Debian 11 now uses php7.4.

The upgrade uninstalled and removed all php7.3 libraries from the server when it upgraded to php7.4.

There’s probably a configuration file somewhere that’s still looking for php7.3.

Confuddled configs:

It’s nginx throwing the error, so lets look in the nginx configuration folder to see if we can find anything.

cd /etc/nginx/

Let’s go a quick and dirty search through the directory to see if there’s any call to php7.3:

grep -R "php7\.3"

And sure enough, we get a match!

sites-available/example.com:        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

Let’s fix it!

At this point, the fix was pretty obvious:

We open sites-available/example.com in our editor of choice. Assuming you’re not working as root, and assuming your $EDITOR variable is set for your prefered editor, the recommended way to do that is:

sudo -e sites-available/example.com


Then we find the fastcgi_pass unix:/var/run/php/php7.3-fpm.sock line, and replace php7.3 with php7.4.

In vim, that command is :%s/php7\.3/php7\.4/g.

Then we just need to restart nginx with the new config, and we’re done!

systemctl restart nginx.service


A quick refresh of the site shows that the 502 error is gone, and WordPress is again working! 👍🏻