Fix: WordPress 502 Bad Gateway Error On Your Own
- Last Updated: Aug 1st, 2018
- Posted by: Editor
- Category: WordPress Knowledge
An error is not just a huddle which stops you to reach your website. It’s a way to realize that something is going wrong with your site and its need to be fixed. Here in this post, we will try to explain the cause of the error and how to fix WordPress 502 bad gateway error?
You always try to visit your website without facing any errors. But some errors like 502 bad gateway error, Page not found 404 error, 500 internal server down stops you to reach your website. Error occurs due to some reason. However, understand those reason can fix the issue.
WordPress 502 Bad Gateway Error: What It Means?
Nowadays web application including a WordPress website is hosted on multiple servers. A couple of servers are enlisted below:
- A web server that serves your website files.
- A database server that runs your WordPress databases.
- The website server that runs the login, PHP code and any other content your WordPress site depends on.
- A gateway server (also known as a reversed proxy server) running software such as Nginx (read as Engine-X), Apache and Varnish among others.
When you visit your WordPress website through any browser. It generates multiple requests for all the parts which combine and create the page you see in a browser.
These requests are transferred to the gateway server which finds out where to send the request. Then, the gateway server retrieves:
- MySQL databases from the database server.
- PHP and the other content from the application server.
A 502 bad gateway error occurs when the gateway servers receive an invalid response from any of the upstream servers (server behind gateway server).
Basically, 502 bad gateway error is an HTTP code which you will get when one server on the internet is not receiving a response from the other. It does not depend on your server setup and this can vary with the server, operating system, and browser.
The different notification you will see when you encounter 502 gateway error:
- “Error 502”
- “HTTP 502”
- “502 Proxy Error”
- “502 Bad Gateway”
- “502 Bad Gateway NGINX”
- “HTTP Error 502 Bad Gateway”
- “502 Service Temporarily Overloaded”
- “502 Server Error: The server encountered a temporary error and could not complete your request”
Cause of 502 Bad Gateway Error
The most common reason for getting 502 bad gateway error is poor communication between your servers. However, this error can occur due to a number of reasons such as:
- Browser cache is acting up.
- Your website server is overloaded.
- You have the Domain Name System (DNS) issues.
- Your Content Delivery Network (CDN) is acting up.
- Problems with your router or networking equipment.
- The speed of Upstream servers is down or can’t be accessed.
- The PHP scripts are full of bugs such as faulty WordPress plugins or themes.
Now let’s move on to fix these errors and make your website error free.
How To Fix WordPress 502 Bad Gateway Error
You never get a clear reason of 502 bad gateway error that’s why to remove this we go through every possible cause of an error and try to fix it:
Reload your WordPress Website
Sometimes your server takes time to respond due to a lower speed and heavy traffic. That’s why you encounter the 502 error. So, Before you try any other method wait for few minutes and reload your website. You can use tools to verify whether your site is down for everyone or for you only.
If the website is down for you only, then the problem is in your end. In this case, you can check your website in the different browser. If the website is down for everyone then you need to proceed further to fix the 502 bad gateway error in WordPress.
Clear Browser Cache
You frequently open your WordPress website in your favorite browser and all of sudden the site start showing 502 bad gateway errors. The simple reason for this is cache saved in your browser.
The modern browser saves the files from your website your frequently open in your browser. Next time when you visit your cache website then the browser doesn’t need to request the same files again and again from the server. Unless you updated the page.
A vigorous caching browser can show 502 bad gateway error. This you can solve by simply clear the cache from your browser and again search for a WordPress site.
Restart Your Networking Equipment
If the changing of browser and clearing cache from a browser is not working for you then move on to next method.
Check out whether your networking equipment is working properly or not. Malfunctioning of Networking equipment can leads to network error 502 bad gateway. Most of the home network have gateway they do especially when your setup involves a router. This can be a source error 502 bad gateway.
To fix this issue Simply, unplug your networking equipment for 60 seconds and plug it again. If you have a router with modem hybrid, plug in the modem first and wait for 60 seconds then plug in the router.
Switch on the equipment and wait for 2 minutes. Now check is it still showing the error or not? Also, restart your device computer or whatever is showing error.
Disable Your CDN Momentarily
CDN (Content delivery network) is a service that transfers files on behalf of your WordPress website and boosts the performance of your website. Example of CDN is CloudFlare but, its free plan causes 502 bad gateway error.
We can check whether the CDN is the reason for a bad gateway error. Simply disable the service temporarily and check the error is still appear or not.
If the error 502 bad gateway is due to CDN then contact the service provider for support.
DNS (Domain name system) Problems
A central part of the internet provides a way to match domain name to IP addresses. If your domain does not reach to right IP address then you encounter with a 502 gateway error. As a matter of fact, when you migrate your domain to a new host this involves the change in DNS name server.
The complete migration task takes between 12 to 36 hours which could result in a bad gateway error? Best is to allow the domain to migrate completely and successfully.
Other then this we can clear the local DNS cache and change DNS on router & devices to avoid bad gateway 502 error.
Fix Error of Your WordPress Plugins & Themes
Poorly coded plugins and theme instigate the scripts and queries that confuse your server. The server is not able to recognize and it cancel the order. That’s why you receive a bad gateway error 502.
The poor coding is not always the reason for gateway error. Besides this plugin using third-party services like reCaptcha also cause the error. Sometimes, NGINX rejects the long tokens generated by Google when showing reCaptcha.
How To Find Out Problematic Plugin
If you think your plugin is creating the issue you can fix this. Access your WordPress root directory and move to the wp-content ➤plugin, and rename the plugin folder. This will deactivate your plugin for a while. Reload your site and check the error is disappear or not. If the error is disappeared then rename the file same as the previous name.
Reactivate your plugin and check the whether the error appears or not. Doing this for all plugin will help you to find out the problematic plugin. You can replace the problematic plugin with other plugin or ask for developer support.
How To Find Out Problematic Theme
If the plugins are not creating the problem then maybe the theme is creating the issue. To find out whether the theme is the reason for bad gateway error access your WordPress root directory via FTP. Move to wp-content ➤theme➤ Your active theme.
Download a copy to your computer as a backup. Now, Click on your active theme and delete it from your WordPress root Directory. Reload your Site if you saw a white screen instead of an error, then there is the problem. Activate your default theme meanwhile fix the problematic theme.
Update WordPress core, Theme & Plugin
Outdated version of WordPress, Theme & plugin conducts errors as well as the security risk. Regular updates can fix the errors and save you from disasters of security.
So, Keep you WordPress, theme & plugin updated to avoid such errors.
Check Your Hosting Server
If all the discussed solution is not working for you then it might be an issue with your hosting server. You need to contact your host server Support team and explain the problem you are facing. Mention all the troubleshooting steps you have taken to fix the issue. All WordPress hosting companies will be able to quickly fix the issue if it is caused by the server.
Hope this beginner guide for fix WordPress 502 bad gateway error. In case of any related problem, contact to our WordPress tech Support team now to get instant help. Dial +1 844 897 0441 (Toll-Free).