How to Fix 502 Bad Gateway Errors on WordPress Website
How to Fix 502 Bad Gateway Error
When it comes to WordPress there are a lot of different errors that can be frustrating and confusing. Another popular one is the 502 bad gateway error.
Why?
This 502 bad gateway error occurs frequently around the internet and also in services such as Gmail, Twitter and Cloudflare.
In this post we will discuss everything you need to know about the 502 bad gateway error what causes this error and some solutions on how to fix and resolve it.
- What is a 502 Bad Gateway Error?
- Causes For 502 Error Bad Gateway?
- How To Fix The 502 Bad Gateway Error?
Table of Content
Below are the content on How to Fix Http 502 Bad Gateway Error.
Click on any of them to get directly to your preferred section or you can scroll down slowly and read from the start.
- What is 502 Bad Gateway Error?
- 502 Errors Impact on SEO of your website
- Causes for 502 Bad Gateway Errors
- Origin Server Is Not Working
- Domain Name System - DNS
- Block Request by Firewall
- Server Failure
- Error in Browser
- 502 Bad Gateway Error Variations
- How to Fix the 502 Bad Gateway Error?
- How to Resolve Http 502 Bad Gateway Error?
- 502 Bad Gateway Error Solutions for Users
- 1. Refresh Or Relead The Page
- 2. Clear Your Browser Cache
- 3. Try In Incognito Mode
- 4. Try Another Browser
- 5. Restart Your Network Device
- 6. DNS Issue
- 502 Bad Gateway Error Solutions for Developers
- 1. Check Your Server
- 2. Check DNS
- 3. Check Local DNS Cache
- 4. Check Plugins & Themes
- 5. Check Error Logs
- 6. Check With Hosting Provider
- 7. Disable CDN or Firewall
- 8. PHP Timeout Issue
Further Reading: How to Encourage More User-Generated Content – UGC
What is 502 Bad Gateway Error?
Every time you visit a website your browser sends a request to a web server. The web server receives and processes the request and then sends back the requested resources along with the Hyper Text Transfer Protocol – HTTP header and HTTP status code – 502 Bad Gateway Error.
This error states there has been an inadequate response from the other server that something has gone wrong along with the code on how to diagnose it. You can see this error on any device, browser and operating system.
There are many different types of 500 status error codes – 500, 501, 502, 503, 504, 520, etc which all have slightly different meanings.
In this case a 502 bad gateway error specifically means that one server while acting as a gateway or proxy has received an invalid response from an inbound server.
Further Reading: 17+ Ways to Boost Low Conversion Rate in E-commerce
502 Errors Impact on SEO of your website
A 502 error can have a negative impact on SEO if not fixed right away.
In the event that this error occurs continuously on your site then it will influence the reputation of your webpage for users as well as for search engines like Google. In the end it would lead to a poor user experience – UX for the customers.
This could impact your rankings. If you are worried about the repeat of 502 bad gateway error then you should figure out why they are happening to begin with and then resolve them as soon as possible.
Most of them represent a server error response and each individual response stand for different server errors which are resolved in different ways.
All server sided errors can only be resolved by webmaster or app builder due to limited server access.
Causes for 502 Bad Gateway Errors
It is an error that you might see because the server was not able to provide a valid response to the request.
There are several other reasons that might lead to a 502 error but here are the most common reasons.
- Origin Server Is not Working
- Domain Name
- Block Request By Firewall
- Server Failure
- Error in Browser
Origin Server Is Not Working
One of the common reasons is that the server is not working as it should which means the server is not accessible.
There are many explanations for this – like the server is down or there is a connectivity problem or there might be a very high amount of traffic on the server.
Domain Name System - DNS
Another reason for seeing a 502 bad gateway error is that the domain is not determining the right IP address.
This usually occurs due to incorrect DNS records being set at the domain hosting level.
If you have set the correct DNS records then keep in mind that changes in DNS can take time to propagate globally and this relies on various factors including Time to Live – TTL especially when moving to a new hosting provider.
Therefore it is always advisable to make sure you or your responsible administrator opt for a trusted and reliable hosting provider like Best-Digital Marketing Services who are able to provide the best and are available when needed.
Block Request by Firewall
The firewall is used to block the transmission between the servers and it is another common reason to face the 502 bad gateway error.
There is also the possibility that your WordPress security plugins might be blocking the communication between servers or even your local or Internet Service Provider – ISP or Internet Protocol – IP address.
To rule this out you can try accessing the site from a different Internet connection. On certain occasions – Distributed Denial of Service – DDOS protection systems can become over-sensitive and start blocking the requests from servers.
With Best-Digital Marketing you will never face the http 502 bad gateway error page due to server inadequacy as we provide dedicated servers with SSD storage, unlimited bandwidth, daily offline backup, daily malware scanning and clean-up, Let’s Encrypt SSL and 24/7 customer support by our experts with a starting price of just £39.99.
Further Reading: How to Write a Good Meta Description for SEO
Server Failure
You might experience a 502 bad gateway error if a server has completely failed and this can be due to a system crash or servers been taken offline for maintenance or similar reasons.
This can also be because the content of the server might be violating the server provider’s terms and conditions.
Error in Browser
Occasionally some browser extensions can also lead to a 502 bad gateway errors when rendering the website especially with Ad Block extensions.
Apart from this there may be the rare occasion where the browser is outdated which is causing the 502 bad gateway errors.
We have discussed the causes of 502 bad gateway errors – now it is time to resolve and fix these 502 bad gateway errors and issues.
Further Reading: Get Traffic to Your Website Fast
502 Bad Gateway Error Variations
Due to the various browsers, web servers and operating systems a 502 bad gateway error can present it in a number of different ways but they all have the same meaning.
If you are experiencing a Server Error or 502 Error when trying to access a site then it means that you are seeing a 502 bad gateway error.
Below are the different variations you might see on the web:
- 502 Bad Gateway NGINX
- 502 Server Error: The server encountered a temporary error and could not complete your request
- HTTP 502
- 502. That’s an error
- 502 Bad Gateway Cloudflare
- Bad Gateway: The proxy server received an invalid response from an upstream server
- Temporary Error (502)
- 502 Bad Gateway
- Error 502
- HTTP Error 502 – Bad Gateway
- 502 Service Temporarily Overloaded
- 502 Proxy Error
- A blank white screen
Here is another variation – 502 – Web server received an invalid response while acting as a gateway or proxy server.
There is a problem with the page you are looking for and it cannot be displayed. When the Web server – while acting as a gateway or proxy contacts the upstream content server, it receives an invalid response from the content server.
Another variation you might see is a 502 server error
Here is a snapshot of how Google displays it – 502. That’s an error. The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. That’s all we know.
Other services like Twitter might even show a completely different message for a 502 Bad Gateway error – Twitter is over capacity and this definitely looks a little more user-friendly.
Further Reading: 31+ Creative Ways How to Drive Traffic to Your Website
How to Fix the 502 Bad Gateway Error
There are a number of things that you can try to resolve this problem. Usually a 502 bad gateway error is a result of bugs in the PHP or the server configuration or network error on the server side.
However it could also be a customer or client side issue like problems with your browser or your ISP or local IP that might be blocking it as mentioned above.
So let us dive in and check out ways how to fix the 502 bad gateway error and get back up and running.
How to Resolve Http 502 Bad Gateway Error
There are a few measures that can be taken to get ahead of the 502 bad gateway error which is caused by either the user or developer’s side.
The common fixes given below are divided into two section:
for the users
for developeres or web administrators
502 Bad Gateway Error Solutions for Users
1. Refresh or Reload the Page
One of the easiest and first things you should try when encountering a 502 bad gateway error is to simply wait a minute or so and then reload or refresh the page by pressing F5 or Ctrl + F5.
It could be that the host or server is simply overloaded with high amounts of traffic and the site will come right back. While you are waiting you could also quickly try a different browser to rule that out as an issue.
Another thing you can do is to paste the website into https://downforeveryoneorjustme.com. This website will tell you if the site is down or if it is a problem on your side.
Further Reading: What is SEO Friendly URL Structure
There is a good chance that the corrupted files stored on your browser might be causing this 502 bad gateway error.
So by clearing the cache of your browser you might be able to resolve this error.
Moreover you should remove the cookies from your browser since this can also help in resolving this error.
Another way to fix this 502 bad gateway error is by starting a new Private or Incognito session in your browser. This should resolve the issue.
Further Reading: What Are The Benefits Of Video SEO?
You can try to use another browser such as Chrome, Safari, Firefox or Internet Explorer.
If you do not see this 502 bad gateway error when you change your browser then this indicates that the problem was your browser.
You can try to re-install the browser to check if this resolves the issue.
To do this – simply switch off your internet router from the mains for about 45 seconds to 1 minute.
Then switch the mains back on and ensure you switch your router power button on too and wait for your computer to establish a connection again. This should alleviate the 502 bad gateway error issues.
A 502 gateway error could also be because of a Domain Name System – DNS issue such as the domain is not resolving to the correct IP address.
If you have just migrated your WordPress site to a new host provider then is it important to wait for things to fully propagate which can take up to 48 hours in some cases.
This will depends upon the Time to Live –TTL value of your DNS records and also check and see if there is no typo errors.
Further Reading: How Much Does Video SEO Cost?
502 Bad Gateway Error Solutions for Developers
If you are a developer or a server manager and you are facing the 502 bad gateway error then the chances that you might be facing this error is because of other factors.
So trying the following solutions should eliminate the issue.
You can determine whether your server is reachable or not by conducting a trace-route or ping test on the server IP.
2. Check DNS
Another way to resolve this 502 bad gateway error is by checking if your fully qualified domain name is resolving properly or not.
You can use the DNS test tools like DNS Checker or MX Tool Box for this purpose. Both are free to use to check your DNS are up and running and correctly configured.
Further Reading: How to Do Keyword Research for SEO – A Simple Guide
3. Clear local DNS Cache
You can also try flushing your local DNS cache to see if this resolves your 502 bad gateway error issue. This is similar to clearing your browser cache.
In Windows simply open up CMD or Command Prompt and enter the following:
ipconfig /flushdns
Command prompt > ipconfig / flushdns
You should see a Successfully flushed the DNS resolver Cache – if it worked correctly.
For MacOS users you can enter the following in the terminal:
dscacheutil -flushcache
Note: There is no success message on Macs.
Finally you can temporarily change your client side DNS servers. By default DNS servers are automatically provided by your ISP but you could temporarily change them to a public DNS server provided by Google.
Most people prefer to use Google’s public DNS constantly because in the long term they are more reliable and a lot faster.
4. Check Your Plugins and Themes
A lot of times the reason for scripts and queries being cancelled by the server is due to bad code on your WordPress site and possibly from a 3rd party plugin or theme.
We have also seen a lot of misconfigured caching plugins generate 502 bad gateway errors.
A few ways you can troubleshoot this is by deactivating all your plugins and remember – you will not lose any data if you simply deactivate a plugin.
A. WordPress Admin Panel
You can do this by accessing your admin through WordPress dashboard, a quick way to do this is to browse to Plugins and select Deactivate from the bulk actions menu.
This will disable all of your plugins and if this fixes the issue then you will need to find the culprit.
Start activating each plugin one by one and reload or refresh the website after each plugin has been activated.
When you see the 502 bad gateway error returns then you have found the culprit plugin. You can either reach out to the plugin developer for help or post a support ticket in the WordPress repository.
Further Reading: Ways To Create Quality Backlinks
B. FTP Client
If you do not have access to the admin panel you can use the File Transfer Protocol – FTP client to connect to your server and rename the plugin folder to something like plugins_old and re- check your site again.
If it works then you will need to test each plugin one by one. Rename your plugin folder back to plugins and then rename each plugin folder inside of if it – one by one until you find the culprit.
Make sure that all your plugins, themes and the WordPress core are updated to the latest version and ensure that you are running a supported version of PHP.
If the plugin contains bad code then you may need to contact the WordPress developers to solve this problem.
5. Check Error Logs
You can also use your error logs which you can view in a section of the hosting dashboard. This can quickly help you narrow down the issue for your 502 bad gateway error issues.
If your hosting provider does not have a logging tool then you could also add the following code to your wp-config.php file to enable the WordPress debug mode:
define('WP_DEBUG',
true
);
define('WP_DEBUG_LOG',
true
);
define('WP_DEBUG_DISPLAY',
false
);
6. Check with Your Hosting Provider
The primary reason we usually see a 502 bad gateway error is due to an issue with the web hosting.
Sometimes when a query, script or request takes longer than it should then it is cancelled or killed by the server.
A lot of hosts especially shared hosts implement what they call a kill script which basically terminates a request after a certain period of time so that it does not take a site down or impact other users.
If you do a Twitter search for bad gateway you can see thousands of tweets happening every day alerting their hosting company of the problem.
One reason you might want to consider moving to a reliable web hosting agency like Best-Digital Marketing Services is that our platform runs in isolation software that contains all of the software resources required to run your site.
This means that the software that runs each site is 100% private and is not shared even between your own sites.
This greatly reduces the chance of seeing a 502 bad gateway error and even if one of your sites does happen to go down – it will not impact any of your other sites.
Many hosts usually offer to upgrade to a more expensive tariff plan to fix this problem and this usually helps to solve this issue which is often not necessary.
Here at Best-Digital Marketing we utilise truly unlimited web hosting this means that every WordPress site is housed in its own isolated location that has all of the software resources required to run it (Linux, Nginx, PHP, MySQL).
Many shared WordPress hosts do not have these capabilities and therefore the server is simply not reachable either because it is down or there is no connectivity.
Further Reading: 5 Trust Badges That Reduce Cart Abandonment for Businesses
7. Temporarily Disable CDN or Firewall
It could also be an issue with your Content Delivery Network – CDN. If you are using a third party CDN provider then an easy way to troubleshoot this is to temporarily disable your CDN.
For example if you are using a free CDN enabler plugin on WordPress then you can simply deactivate the plugin and test your site.
If you are unable to access your site’s dashboard then simply log in to your site via Secure File Transfer Protocol –SFTP and rename the plugin’s folder to cdn-enabler_old.
This will temporarily disable the CDN connection. The same goes for WP Rocket or any other plugin you might have hooked up to your CDN.
This can also occur sometimes with providers that provide DDoS protection and mitigation or fully proxy services like Cloudflare since they have extra firewalls in-between.
Many users noticed that this issue happens once in a while on Cloudflare’s free plan. Unfortunately since Cloudflare is a complete proxy service there is no quick way to disconnect it.
However before you go blaming Cloudflare it is important to know that there are two different types of 502 bad gateway error variations with Cloudflare as seen below:
A. 502 Bad Gateway at Cloudflare (Variation 1)
If you see the following screen, this is actually a problem on Cloudflare’s end which means that you should reach out to them for support check their status page to see if they are currently experiencing any outage.
B. 502 Bad Gateway at Cloudflare (Variation 2)
If you see the following screen then this is a problem with your hosting server.
Further Reading: How to Find and Fix Broken Links in WordPress
8. PHP Timeout Issue
PHP timeouts occur if a single PHP process runs for longer than the max_execution_time or max_input_time set in the PHP configuration on your server.
This is a common occurrence if you are carrying out huge WordPress imports and a 502 server error is usually displayed.
If you run into a PHP timeout these values may need to be extended. You can check with your current host to enquire the current values set on your server and if they can be increased.
On our platforms at Best-Digital Marketing these values are set to 300 seconds or 5 minutes by default. The maximum PHP timeout values available on our platform are based on your current hosting plan.
max_execution_time
=300
Conclusion
There are quite a few things you can do to troubleshoot and fix a 502 gateway error on your WordPress site. Usually this is not on the client-side but rather an issue with your host- server side.
Third-party plugins and themes with bad code or un-optimised queries are also things to watch out for.
If you enjoyed this post then please share it on social media and you will love our hosting platform. Turbocharge your website and get 24/7 support from our expert team.
Our plans have powerful infrastructure focusing on auto-scaling, performance and security. Let us show you the difference – Check out our plans or chat with us today to find the plan that is right for you.
For full Web Hosting Services package functionality
and select the package that suits your business needs.
If you prefer to discuss your requirements first just
or fill your details with a message of your requirements at
Further Reading: Benefits of SEO
For more information about our services and how we can help you with Web Hosting Service needs:-
Join Our Blog Email List
I might send you 1 or 2 emails a month. Most probably less. Lots of tricks, tips, humour hacks, guides and exclusive ramblings in there for your good mental health and education.
You can unsubscribe anytime whenever you like. No risk or regrets. We will never spam your Inbox.
Hope you are enjoying and learning a lot with abundance of information about:-