[ad_1]
[ad_2]
I get this error almost on every page but when I refresh it, it always works on the second try.
Here's what the error logs say: [error] 36903#36903: *6006 FastCGI sent in stderr: "usedPHP message: Connection refusedPHP
I have a lightsail instance with Linux/Unix Ubuntu server running nginx with mysql and php-fpm for a WordPress site. I installed redis and had a lot of problems so I removed it and I'm thinking the error is related to this.

What size Lightsail instance? You’ve probably run out of memory. Redis would exacerbate that problem. Have you looked at `top`?
The “502 Bad Gateway” error you’re encountering is a common issue in Nginx when there is a problem with the communication between Nginx and the backend service, in your case, PHP-FPM.
Ensure that PHP-FPM is running by running this command: sudo systemctl status php7.4-fpm
Restart the PHP-FPM service using this command: sudo systemctl restart php7.4-fpm
PS: change the php version to what you have installed.
Also, Ensure that the “fastcgi_pass” directive in your Nginx configuration is pointing to the correct PHP-FPM socket which is:
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;