In this tutorial we will show you how to fix 502 bad gateway error on Nginx web server. If you run a Nginx web server you may have already encountered the annoying 502 bad gateway errors. This is pretty common error, are generated most probably by the PHP or FastCGI buffer and timeouts settings. This tutorial shows you how to fix nginx 502 bad gateway on the nginx webserver. This post shows how to fix this problem, and the configuration option to prevent it occurring again on reboot.
This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step solve 502 bad gateway error on Nginx web server.
Fix 502 Bad Gateway Error on Nginx
Method 1. Changes in Nginx Config
Method 2. Change PHP-FPM to listen on a unix socket or TCP socket.
If you are configuring php-fpm to listen on a Unix socket, you should also check that the socket file has the correct owner and permissions.
Method 3. Disable APC.
Congratulation’s! You have successfully solved 502 bad gateway issues. Thanks for using this tutorial to fix 502 bad gateway issues on Linux system. For additional help or useful information, we recommend you to check the official Nginx web site.