Running WordPress blog/site, you might have faced 502 bad gateway error once in a while. Right? I’m sure you did.
However, this is one of the most popular error messages on the Internet. This also happens with popular services such as Gmail, Twitter, etc. But that does not mean taking it lightly. Driving a blog/site also requires care. Of course, we have to do, because we can only care about how it impacts your WordPress site.
Facing such error sometimes is quite frustrating, challenging and confusing as well. Don’t panic, Let’s know it in detail.
What is 502 Bad Gateway Error?
It is an HTTP status code that suggests one server on the internet received an invalid response from another server.
Let me explain,
Whenever you visit any website, the client (your browser) sends a request to a web server. The server then responds to the client request by using a proxy or a gateway. If the proxy or gateway received an invalid response from the server, it generates the HTTP 502 Bad Gateway Error.
This error seems in variations according to browsers, web servers, and operating systems. The variations are as follows:
- 502 Bad Gateway
- Error 502
- HTTP Error 502 – Bad Gateway
- 502 Service Temporarily Overloaded
- 502 Proxy Error
- 502 Server Error: The server encountered a temporary error and could not complete your request
- HTTP 502
What causes the 502 Bad Gateway Error?
The error may arise because of following reasons:
- The origin server cannot be reached.
- If there are any issues with your internet browser and it cannot access the website or a web page.
- If the server is down and cannot be accessed.
- If the server has become overloaded.
- The Internet gateway or router is unable to pull content from the origin server.
This is all about HTTP 502 error that we have to fix it before it affects your blog/site. It is as same as you provide medication to yourself when you fall sick. At last, it is your website and you have to care it for multiple reasons including better SEO, good ranking etc.
So now, let’s jump to the point – How to fix 502 error?
It can be sometimes client side and sometimes server side issue. So we will cover both.
How to Fix 502 Bad Gateway Error?
1. Check if Website is really down:
The primary task you have to do after noticing the error message is to check whether the site is really down. There are various web tools available for this task, that may help you.
2. Try Reloading the page:
Sometimes the arises for temporary only. It could be frequently the host or server is overloaded and your site will make revival after an instance.
3. Clean Caches and Cookies:
Stored cache in a browser while checking site provide a cached version of the site that may confuse you. thus, it is better to clean your browser cache.
If the browser gets overloaded with cookies, it may generate the error. Clean your browser cookies and lets the browser store fresh cookies.
4. DNS issue:
The error may take place due to DNS issue, for example – the domain is not able to resolve correct IP.
Try flushing your DNS cache. For that do the following steps:
- Open the command prompt on your computer.
- Enter command:
- A message will appear: Successfully flushed the DNS Resolver Cache
- For macOS users, enter command,
5. Check with your Host:
If there is a problem with the web host, the error may take place. Sometimes a query or request take a long time to respond. Thus, it gets declined by web server i.e., the server terminates the request so that it doesn’t take a site down or impact other users.
6. Check your Plugins and Themes:
Make sure you are not using 3rd party plugins or themes. Using them generates bad code in your WordPress site and you regularly likely to face such or likewise errors.
In addition, misconfigured plugins also generated the error. Fixing the error requires deactivating such plugins.
A similar thing happens if using 3rd party themes. So, make sure you are using the theme from a trusted party and ask your theme developer to configure it properly.
7. Check Error logs:
Your hosting provider facilitates error log. Take benefit of it and quickly identify what’s going wrong with your WordPress site.
8. Disable CDN for temporary:
The error may generate if there is an issue with your CDN (Content Delivery Network). An easy way to fix it by temporarily disabling it.
Most of the bloggers more likely to use CDN enabler plugin. Deactivate it and test your site. In case, you are unable to login your WordPress dashboard, then
- Login into your SFTP.
- Rename the plugin’s folder to CDN-enabler_old.
- Doing this will temporarily disable CDN connection.
For the users who use CloudFlare:
CloudFlare is a fully proxy service. Thus, you can’t disable it quickly. But, before blaming CloudFlare, it is essential to confirm whether the problem arising from your end or by CDN. There are two ways to identify it:
- Variation 1:
If you notice following screen, then it is the problem with CDN. You have to contact them for support:
2. Variation 2:
If you see the following screen, this is a problem with your host.
There are few things you can do to troubleshoot and fix a 502 gateway error. I hope, trying these ways help you best in fixing 502 error. Feel free to ask any doubts in the comment section below.