<\/span><\/h2>\nA 502 bad gateway error is usually an issue with the network or server. But, it can also be a client side issue. So we will troubleshoot the error within the server, and the client side as well. The following are some steps to check and solve the issues.<\/p>\n
1. Check your server<\/h3>\n <\/p>\n
If you are seeing the error as shown in the picture, most probably the error is within your webserver. \nLet’s check your webserver configuration, in this case the server is running Nginx. WordPress is running on PHP and MySQL. So, in nginx we need to check how PHP files are processed. Find the “location ~ \\.php$” in your nginx server block.<\/p>\n
ssh@your_ip -p7022<\/pre>\n <\/p>\n
According to the nginx configuration as shown in the picture, the PHP files are processed by fastcgi that is running on port 9000. \nLet’s check what is running on the port<\/p>\n
netstat -pltn | grep 9000<\/pre>\nIf you don’t see any result after issuing the command, then the process is died. This is why you see the 502 bad gateway error.<\/p>\n
In latest CentOS and Ubuntu, you can invoke this command to see where the process should be ran from:<\/p>\n
systemctl list-unit-files | grep fpm<\/pre>\n <\/p>\n
Issue this command to run the service:<\/p>\n
systemctl start php7.0-fpm<\/pre>\nNow, go to your web browser and check your website.<\/p>\n
If you use CloudFlare and see the 502 bad gateway error as shown in the picture below, most likely your web server is down. You can try restarting apache or nginx, depends on which web server you use.<\/p>\n
<\/p>\n
2. Clear your cache.<\/h3>\n If the first solution has been done, but you still see the 502 bad gateway error, then your web browser is still relying on its cache. We have to tell the web browser to load the latest version from the site. We can do this by pressing Ctrl + F5 on the keyboard (Windows\/Linux), or Shift + Reload button in the toolbar (Safari browser), or CMD + Shift + R (Chrome and Firefox for Mac users).<\/p>\n
3. Disable CDN<\/h3>\n If you are using CloudFlare, you can try disabling CDN for a while.<\/p>\n
<\/p>\n
4. Check your scripts<\/h3>\n As previously said, a 502 bad gateway error is due to an issue with the web server. Sometime, the php processes are killed by the server due to high memory usage, for example. This killing process will terminate requests after a certain of time, this will also cause the website down. But, usually the website will be automatically accessible because php processes is respawned at that time. To solve this issue permanently, you need to check which php script is consuming high memory.<\/p>\n
5. Check Plugins and Themes<\/h3>\n To troubleshoot which plugin is causing the error is very simple. Even we don’t have access to our WordPress backend, we can disable all plugins at once by renaming the plugins directory. To do it, please connect to your server using SSH. Note that you can also do this using an FTP client, like FileZilla.<\/p>\n
\nYou can enable plugins one by one, please follow these steps: \nGo to your wp-content directory, we can see that there is no plugins directory, we renamed it already. \nLet’s create a plugins directory and move a plugin over. This will automatically enable the plugin.<\/p>\n
<\/p>\n
Sometimes, troubleshooting WordPress errors is easier than we might think. But, also it could be very hard to solve at some point.<\/p>\n
\nOf course, you don\u2019t need to get troubled with your server if you have a WordPress\u00a0VPS<\/a>\u00a0hosted with us \u2013 in which case, our technical support team will help you investigating and solving this 502 Bad Gateway issue immediately. They are available 24\/7, and can cater to any questions or requests.<\/p>\nPS.<\/strong>\u00a0If you liked this post, feel free to share it with your friends by using the social media share shortcuts below, or simply leave a comment. Thanks.<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":"
Have you ever seen the very annoying and frustrating 502 bad gateway error on a WordPress site? Yes, I think … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":27083,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1710,1701],"tags":[1717,148],"yoast_head":"\nHow to Fix the 502 Bad Gateway Error in WordPress - RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n