When it comes to WordPress, at that place are a lot of different errors that can be downright frustrating and disruptive. A few that come up to listen are the white screen of death or the frightening error establishing a database connection. But an even more popular i is the 502 bad gateway mistake. Why? Because this regularly happens around the entire web, not only to WordPress sites, but fifty-fifty pop services such as Gmail, Twitter, and Cloudflare. But of class, nosotros really only care about how it impacts your WordPress site. Read more beneath nigh what causes this fault and some solutions on how to quickly resolve it.

  • What Is a 502 Bad Gateway Mistake?
  • How to Fix the 502 Bad Gateway Error

What is a 502 Bad Gateway Error?

The 502 Bad Gateway error specifically means that the server received an invalid response from an inbound server.

The Internet Engineering science Task Force (IETF) defines the 502 Bad Gateway error as:

The 502 (Bad Gateway) status code indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.

Every time you visit a website your browser sends a asking to a web server. The web server receives and processes the request, and and then sends back the requested resources forth with an HTTP header and HTTP status code. Typically an HTTP status lawmaking isn't seen unless something goes wrong. Information technology's basically the servers mode of notifying you that something has gone wrong, along with the lawmaking on how to diagnose information technology.

There are many dissimilar types of 500 status error codes (500, 501, 502, 503, 504, 508, 520, etc.) which all accept slightly different meanings. These indicate that the request was accepted, simply the server prevented the fulfillment of the request.

502 bad gateway error in Chrome
502 bad gateway error in Chrome

502 Bad Gateway Error Variations

Due to the various browsers, web servers, and operating systems, a 502 bad gateway fault can present itself in a number of different ways. But they all take the same meaning. Below are simply a couple of the many different variations you might encounter on the web:

  • "502 Bad Gateway"
  • "Error 502"
  • "HTTP Error 502 – Bad Gateway"
  • "502 Service Temporarily Overloaded"
  • "502 Proxy Fault"
  • A bare white screen
  • "502 Server Mistake: The server encountered a temporary fault and could not consummate your request"
  • "HTTP 502"
  • Temporary Fault (502)
  • 502. That's an mistake
  • 502 bad gateway Cloudflare
  • Bad Gateway: The proxy server received an invalid response from an upstream server

Some other variation you might see is a "502 server mistake."

502 server error in Chrome
502 server error in Chrome

And here is yet another variation. "502 – Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the folio you are looking for, and it cannot be displayed. When the Web server (while acting equally a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server."

502- web server received an invalid response
502- web server received an invalid response

Other services such as Twitter might even show a completely different bulletin for a 502 Bad Gateway mistake, such as "Twitter is over capacity." This definitely looks a fiddling more convenient.

Twitter is over capacity
Twitter is over capacity (Img src: Softpedia)

And hither is a snapshot of how Google displays it. "502. That'southward an fault. The server encountered a temporary error and could non complete your request. Please endeavor again in 30 seconds. That's all we know."

Google 502 error
Google 502 mistake

502 Errors Touch on on SEO

Different 503 errors, which are used for WordPress maintenance mode and tell Google to bank check back at a after time, a 502 fault tin have a negative impact on SEO if non fixed right away. If your site is only down for say 10 minutes and it'due south being crawled consistently a lot of times the crawler will merely get the folio delivered from cache. Or Google might not even have a chance to re-clamber it earlier information technology's support. In this scenario, yous're completely fine.

Nevertheless, if the site is downwardly for an extended flow of time, say 6+ hours, then Google might see the 502 error every bit a site level result that needs to be addressed. This could impact your rankings. If you're worried about repeat 502 errors you should effigy out why they are happening to begin with. Some of the solutions below can help.

How to Fix the 502 Bad Gateway Error

A 502 bad gateway fault is typically a problem with the network/server, nevertheless, it can likewise be a client-side result. And so nosotros'll dive into a little of both. Cheque out these common causes and ways to fix the 502 bad gateway error to and get back up and running.

1. Effort Reloading the Folio

I of the easiest and first things you should endeavour when encountering a 502 bad gateway error is to simply wait a infinitesimal or so andreload the page (F5 or Ctrl + F5). Information technology could exist that the host or server is simply overloaded and the site will come up correct dorsum. While you lot're waiting, you could too quickly try a different browser to rule that out as an issue.

Another affair you lot tin do is to paste the website into downforeveryoneorjustme.com. This website will tell you if the site is down or if it's a problem on your side.

downforeveryoneorjustme
downforeveryoneorjustme

2. Clear Your Browser Cache

Whenever you come across bug like these it can be skillful to clear your browser cache. Beneath are instructions on how to do information technology in the various browsers:

Subscribe Now

  • How to Force Refresh a Single Page for All Browsers
  • How to Clear Browser Enshroud for Google Chrome
  • How to Clear Browser Enshroud for Mozilla Firefox
  • How to Clear Browser Cache for Safari
  • How to Clear Browser Cache for Net Explorer
  • How to Clear Browser Cache for Microsoft Edge
  • How to Clear Browser Cache for Opera

3. DNS Issue

A 502 gateway error could also be because of a DNS outcome, such as the domain is not resolving to the correct IP, or the DNS server is not responding. If you take just migrated your WordPress site to a new host, is it of import to wait for things to fully propagate, which tin take upwardly to 24 hours in some cases. This depends upon the TTL value of your DNS records.

You lot tin also try flushing your local DNS cache. This is similar to clearing your browser cache.

In Windows merely open Command Prompt and enter the following:

ipconfig /flushdns
Command prompt - flush DNS
Command prompt – flush DNS

You should see a "Successfully flushed the DNS resolver Cache" if it worked.

For macOS users, you tin can enter the following in the final:

dscacheutil -flushcache

Annotation: There is no success bulletin on Macs.

And lastly, yous could temporarily alter your DNS servers. By default, DNS servers are automatically assigned by your ISP. Only you could try temporarily irresolute these to a public DNS server, such every bit Googles. In fact, some prefer to utilize Google's public DNS long-term. If you lot have a premium DNS propagation usually is a lot faster.

4. Cheque With Your Host

The primary reason we typically see a 502 bad gateway error is due to an issue with the web host. Sometimes aquery, script, or request will take too long and then it is canceled or killed by the server. A lot of hosts, peculiarly shared hosts implement what they telephone call a "kill script." Basically what this does is it will terminate a request later a certain period of time so that information technology doesn't take a site down or bear upon other users. If you do a Twitter search for "bad gateway" you tin see thousands of tweets happening every day alerting their hosting company of the problem.

502 bad gateway tweets
502 bad gateway tweets

1 reason yous might want to consider moving to a host similar Kinsta is that our platform runs in anisolated software container that contains all of the software resources required to run the site (Linux, NGINX, PHP, MySQL). This means that the software that runseach 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. Nosotros aren't running aggressive kill scripts similar some shared hosts are. And fifty-fifty if one of your sites does happen to go downward, it won't impact your other sites.

Another reason you could see a 502 gateway fault with your host is also due to the fact that the server is simply non reachable, either considering it is down or there is no connectivity. In this instance, it is recommended to cheque your WordPress host's status page or open up a support ticket.

5. Temporarily Disable CDN or Firewall

Information technology could also be an outcome with your content delivery network (CDN) or firewall. If you are using a 3rd-political party CDN provider an easy way to troubleshoot this is to but disable your CDN temporarily. For instance, we are big fans of the free CDN enabler plugin. If you are using that, you can just deactivate the plugin and and so exam your site. Wp-admin non working? Simply log in to your site via SFTP and rename the plugin'due south folder to cdn-enabler_old. This will temporarily disable the CDN connection. The same goes for WP Rocket or any other plugin yous might accept hooked up to your CDN.

Rename plugin folder temporarily
Rename plugin binder temporarily

This can likewise occur sometimes with providers that provide DDoS protection and mitigation or fully proxy services similar Cloudflare, as they have actress firewalls in-between. Nosotros accept noticed that this happens in one case in a while on the Cloudflare free programme. Unfortunately, since Cloudflare is a fully proxy service, there is no quick way to simply disable it.

Still, earlier you become blaming Cloudflare, it is of import to know that there are 2 unlike types of 502 bad gateway errors variations with Cloudflare as seen beneath:

502 Bad Gateway at Cloudflare (Variation 1)

If you run across the following screen, this is really a trouble on Cloudflare'south end, in which case y'all should accomplish out to them for back up. Y'all can besides check Cloudflare's condition folio to see if they're currently experiencing an outage.

502 bad gateway error
502 bad gateway error

502 Bad Gateway at Cloudflare (Variation 2)

If you come across the following screen, this is a problem with your host.

Cloudflare 502 bad gateway at host
Cloudflare 502 bad gateway at host

GoDaddy Firewall

Here is another case with of an HTTP 502 mistake and GoDaddy'southward firewall. The issue is actually with the origin server (the hosting provider) due to a timeout, not the firewall itself.

HTTP 502 - GoDaddy Firewall
HTTP 502 – GoDaddy Firewall

6. Cheque Your Plugins and Themes

A lot of times the reason for scripts and queries being canceled past the server is due tobad lawmaking on your WordPress site, perhaps from a 3rd party plugin or theme. Nosotros have also seen a lot of misconfigured caching plugins generate 502 errors. A few ways you tin troubleshoot this is by deactivating all your plugins. Think, you won't lose any data if you simply deactivate a plugin.

If you can however admission your admin, a quick way to practice this is to browse to "Plugins" and select "Deactivate" from the bulk deportment menu. This will disable all of your plugins. If this fixes the issue you'll need to find the culprit. Start activating them ane by ane, reloading the site afterward each activation. When you see the 502 gateway error return, yous've found the misbehaving plugin. You can then reach out to the plugin developer for help or post a support ticket in the WordPress repository.

Deactivate all plugins
Deactivate all plugins

If you can't access your admin you tin can FTP into your server and rename your plugins folder to something similar plugins_old. Then bank check your site again. If it works, and then you will need to test each plugin ane by i. Rename your plugin folder back to "plugins" and then rename each plugin binder within of if it, one by one, until you discover it.

Rename plugin folder
Rename plugin folder

E'er makes certain your plugins, themes, and WordPress core are up to date. And check to ensure y'all are running a supported version of PHP. Y'all tin can always reach out to your host for assistance. Nosotros utilize New Relic and other troubleshooting methods here at Kinsta to aid clients narrow down what plugin, query, or script might be causing the error. You lot tin besides use your ain custom New Relic key.

Time consuming queries to database
Time-consuming queries to the database

If it turns out to be an efficient query or bad lawmaking in a plugin, you might need to bring in a WordPress developer to fix the issue.

7. Cheque Logs

Yous should also have advantage of your error logs. If yous are a Kinsta client, you tin easily see errors in the log viewer in the MyKinsta dashboard. This tin can help you quickly narrow down the result, especially if it'due south resulting from a plugin on your site.

Check error logs for 502 bad gateway errors
Bank check fault logs for 502 bad gateway errors

If your host doesn't have a logging tool, you tin can too add the following lawmaking to your wp-config.php file to enable logging:

          define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', imitation );        

If you lot need more than assist on how to enable WordPress debugging way here is a full step past pace tutorial.

The logs are typically located in the /wp-content directory. Others, like here at Kinsta might have a defended folder called "logs".

wordpress error logs folder sftp

You can also check the log files in Apache and NGINX, which are commonly located hither:

  • Apache: /var/log/apache2/mistake.log
  • NGINX: /var/log/nginx/error.log

If you are a Kinsta client you tin can also take advantage of our analytics tool to get a breakdown of the total number of 502 errors and see how often and when they are occurring. This can help you troubleshoot if this is an ongoing upshot, or peradventure something that has resolved itself.

Response analysis 500 error breakdown
Response assay 500 mistake breakdown

8. Restart PHP

Finally, you can also try restarting PHP. If you're a Kinsta client, yous tin can easily restart PHP from the tools menu inside the MyKinsta dashboard. If your host doesn't provide this, you can ever open upwardly a back up ticket and inquire them restart PHP.

Restart PHP
Restart PHP

ix. PHP Timeout Issue

PHP timeouts occur if a single PHP procedure 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're doing big WordPress imports. When this happens a 502 server error is normally displayed. If you run into a PHP timeout these values may need to exist elevated.

You can check with your current WordPress host most what values are assault your server and if they tin can be increased. On the Kinsta platform, these values are set to 300 seconds (5 minutes) by default. The maximum PHP timeout values available on our platform are based on your current hosting plan.

Summary

As you lot can run across at that place are quite a few things you can do to troubleshoot and fix a 502 gateway error on your WordPress site. Typically this is not on the customer-side, but rather an consequence with your host. Third-party plugins and themes with bad code or unoptimized queries are also things to picket out for. Was there anything we missed? Perhaps you have another tip on troubleshooting 502 gateway errors. If so, permit us know below in the comments.


Save fourth dimension, costs and maximize site performance with:

  • Instant aid from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience attain with 29 data centers worldwide.
  • Optimization with our built-in Awarding Performance Monitoring.

All of that and much more than, in ane plan with no long-term contracts, assisted migrations, and a xxx-day-money-back-guarantee. Bank check out our plans or talk to sales to find the plan that'southward right for yous.