A 502 Bad Gateway error is an HTTP status code indicating that a server acting as a gateway or proxy received an invalid response from the upstream server. In simple terms: there is a communication issue between various servers necessary for your website to function.
The main thing to know is that this is a server-side error. This means the problem almost always lies with the website or hosting provider, not with you as a visitor. The error can appear on any website, in any browser, and on any device: from your smartphone to your laptop.
What does a 502 Bad Gateway error look like?
Depending on your browser and the website, 502 errors can look different:
- “502 Bad Gateway”
- “Error 502”
- “HTTP Error 502 – Bad Gateway”
- “502 Service Temporarily Overloaded”
- “502 Proxy Error”
- A white screen without text
- “502 Server Error: The server encountered a temporary error and could not complete your request”
- “502. That’s an error” (Google)
- “502 bad gateway Cloudflare”
Large platforms like X often display more user-friendly messages such as “X is over capacity” instead of the technical error code.
Causes of a 502 Bad Gateway error
Server overload
The most common cause is that the server simply cannot handle the amount of traffic. This occurs especially during sudden traffic spikes or when server resources are insufficient for the number of visitors.
Network issues
Errors in communication between different servers can cause a 502 error. This may be due to firewall settings that incorrectly block traffic, routing issues, or unstable network connections between servers.
Web server software errors
A crash or incorrect configuration of web server software like Nginx or Apache can prevent servers from communicating correctly with each other. Also, updates that are not executed properly can cause this.
Issues with PHP-FPM
For websites using PHP (such as WordPress sites), an issue with PHP-FPM might be the cause. This service that executes PHP scripts can become unresponsive, inaccessible, or incorrectly configured.
PHP timeout problems
PHP timeouts occur when a PHP process takes longer than the set max_execution_time or max_input_time. This often happens when performing large WordPress imports or other resource-intensive processes.
Browser cache
Sometimes your browser has stored an outdated version of the page containing the 502 error, causing you to keep seeing the error even though the problem on the server side has been resolved.
DNS issues
When the domain name is not correctly translated to the right IP address, this can cause a 502 error. This mostly occurs after recent DNS changes that have not yet been fully propagated.
Impact of 502 errors on SEO
Unlike 503 errors (used for maintenance periods), 502 errors can negatively impact your SEO.
If your website is offline for 10 minutes and is consistently crawled by Google, the bot will likely load the page from the cache. Google may not even have the chance to crawl again before your website is back online. In this case, there’s no problem.
However, if your website is offline for a longer period (6 hours or more), Google might interpret this as a structural problem that needs addressing. This can impact your ranking. In the case of repeated 502 errors, it’s important to find and resolve the underlying cause.
How to fix a 502 error as a visitor?
1. Reload the page
Always start with the simplest step: reload the page. Many 502 errors are temporary and resolve on their own. Use the shortcut F5 or Ctrl+R (Cmd+R on Mac) to refresh the page.
2. Clear browser cache and cookies
Clear your browser cache and cookies to ensure you’re not viewing outdated data that keeps the error persistent. In Chrome, go to Settings > Privacy and security > Clear browsing data.
3. Try a different browser or incognito mode
Test whether the error also occurs in another browser or in an incognito/private window. This helps rule out issues related to browser settings, extensions, or stored data.
4. Clear DNS cache
Clear your local DNS cache. This is similar to clearing your browser cache but for DNS information:
Windows: Open Command Prompt and enter:
ipconfig /flushdnsmacOS: Open Terminal and enter:
dscacheutil -flushcache5. Restart network equipment
Turn off your modem and router, wait 30 seconds, and turn them back on. Sometimes local network issues can cause or exacerbate a 502 error.
6. Check if the website is down for everyone
Use a tool like downforeveryoneorjustme.com to check if others are also experiencing the problem. If the site is down for everyone, the issue is definitely on the server side.
How to fix a 502 error as a website owner?
1. Check the server logs
Start by checking your error logs and access logs. Look for specific error messages around the time the 502 error appeared.
Logs can typically be found at the following locations:
- Apache:
/var/log/apache2/error.log - NGINX:
/var/log/nginx/error.log - WordPress: In the
/wp-content/folder
2. Enable WordPress debugging
If you are using WordPress and do not have access to server logs, add this code to your wp-config.php file:
phpdefine( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );3. Check for server overload
Check the CPU and memory usage of your server. If these resources are fully utilized, this is likely the cause of your problem. Consider temporarily scaling up server resources or limiting traffic.
4. Restart services
Restart your web server (Nginx or Apache) and PHP-FPM service. This is often a quick fix for temporary software issues. On shared hosting, you can usually do this through your hosting control panel.
5. Check PHP timeout settings
In the case of PHP timeout issues, the max_execution_time and max_input_time values may need to be increased. Contact your hosting provider to ask what the current values are and if they can be adjusted.
6. Check the firewall and CDN
Ensure your firewall is not incorrectly blocking communication between different servers. Temporarily disable your CDN to test if this is causing the issue.
Note with Cloudflare: There are two different 502 variants:
- Cloudflare issue: “502 Bad Gateway” with Cloudflare branding – contact Cloudflare
- Hosting issue: “Bad Gateway: The proxy server received an invalid response” – contact your hosting provider
7. Check plugins and themes
For CMS systems like WordPress, a faulty plugin or theme can overload the server. Temporarily disable all plugins by:
- Via dashboard: Bulk action > Deactivate all plugins
- Via FTP: Rename the
pluginsfolder toplugins_old
Then activate plugins one by one to identify the cause.
8. Contact your hosting provider
If you can’t resolve it yourself, contact the support of your hosting provider. They can check the server status and often see directly where the problem lies. Always provide the exact time when the error occurred.
Conclusion
A 502 Bad Gateway error is annoying but usually temporary. As a visitor, it’s usually just a matter of waiting: the error is almost always on the server side and is typically resolved within a few minutes to hours.
For website owners, a 502 error is an important warning to examine server configuration and performance. It may indicate structural issues that can be proactively addressed, such as insufficient server resources, PHP timeout problems, or configuration issues.
With repeated 502 errors, it is important to act quickly due to the potential negative impact on your SEO.
And remember: when in doubt, always ask your hosting provider for help.



Leave a Reply