{"id":8060,"date":"2018-04-23T12:09:10","date_gmt":"2018-04-23T12:09:10","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=8060"},"modified":"2026-11-20T18:02:49","modified_gmt":"2026-11-20T18:02:49","slug":"how-to-fix-502-bad-gateway-error-2","status":"publish","type":"post","link":"\/my\/tutorials\/how-to-fix-502-bad-gateway-error-2\/","title":{"rendered":"How to fix the 502 Bad Gateway error"},"content":{"rendered":"<p class=\"wp-block-paragraph\">A 502 Bad Gateway error occurs when a server acting as a gateway or proxy receives an invalid response from the upstream server. Common causes include an overloaded server, a problem with the application behind the proxy, or an incorrect proxy setting.<\/p><p class=\"wp-block-paragraph\">If you&rsquo;re visiting the site, reload the page and check whether it&rsquo;s down for others. If the error only appears on your end, try a private window, clear your browser or DNS cache, or test from another device or network.<\/p><p class=\"wp-block-paragraph\">If you own the site and multiple visitors see the error, start with your error logs. Check for recent plugin or theme changes, CDN issues, and PHP timeouts. If the error persists, verify that the proxy can reach the application or ask your hosting provider to check the connection.<\/p><p>\n\n\n<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2021-07-502-featured\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/07\/502-Featured-Graph.png\"><img decoding=\"async\" width=\"768\" height=\"274\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2021\/07\/502-Featured-Graph.png\/public\" alt=\"Infographic detailing the 502 bad gateway error\" class=\"wp-image-32717\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2021\/07\/502-Featured-Graph.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2021\/07\/502-Featured-Graph-300x107.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2021\/07\/502-Featured-Graph-150x54.png 150w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n<\/div><h2 id=\"h-what-causes-a-502-bad-gateway-error\" class=\"wp-block-heading h-t-title-2\">What causes a 502 Bad Gateway error?<\/h2><p class=\"wp-block-paragraph\">A 502 Bad Gateway error is an <a data-click-id=\"hgr-post-content-link-http-status-code\" href=\"\/my\/tutorials\/http-status-codes\/\">HTTP status code<\/a> that occurs when one server is not able to communicate properly with another server.<\/p><p class=\"wp-block-paragraph\">The root cause can be server communication problems, network connectivity issues, overloaded servers, misconfigurations, or faulty applications that prevent proper data exchange between systems.<\/p><p class=\"wp-block-paragraph\">Here are the main causes and what they mean:<\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Cause<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>Server overload<\/td><td>The upstream server is receiving too many requests and can&rsquo;t respond in time.<\/td><\/tr><tr><td>Network connectivity issues<\/td><td>Problems with internet connections between servers, including timeouts or dropped connections.<\/td><\/tr><tr><td>Server downtime<\/td><td>The upstream server is temporarily offline for maintenance or has crashed.<\/td><\/tr><tr><td>Firewall restrictions<\/td><td>Security settings blocking communication between servers.<\/td><\/tr><tr><td>DNS problems<\/td><td>Domain name resolution issues preventing servers from finding each other.<\/td><\/tr><tr><td>Proxy or gateway misconfiguration<\/td><td>Incorrect settings on the intermediate server handling requests.<\/td><\/tr><tr><td>Application errors<\/td><td>Bugs or crashes in the web application code causing invalid responses.<\/td><\/tr><tr><td>CDN issues<\/td><td>Problems with content delivery network servers distributing your content.<\/td><\/tr><tr><td>Database connection problems<\/td><td>The web server can&rsquo;t connect to the database to retrieve information.<\/td><\/tr><tr><td>PHP or other script timeouts<\/td><td>Scripts taking too long to execute and timing out before completion.<\/td><\/tr><\/tbody><\/table><\/figure><p class=\"wp-block-paragraph\">The tricky part is that 502 errors can look the same to users even when they have completely different underlying causes. That&rsquo;s why troubleshooting often involves testing multiple solutions to find what works.<\/p><p class=\"wp-block-paragraph\">This video walks you through the most common ways to troubleshoot a 502 Bad Gateway error.<\/p><figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Quickly Fix 502 Bad Gateway Error\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/T15thZb4TXg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure><p>\n  <div class=\"youtube-shortcode\">\n    <div class=\"row\">\n      <div class=\"col-7 col-sm-8 d-flex align-items-center\">\n        <img decoding=\"async\" class=\"channel-logo\" src=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/youtube-channels\/hostinger-academy.jpg\" alt=\"youtube channel logo\">\n        <div class=\"d-flex flex-column justify-content-between\">\n          <span class=\"slogan d-none d-sm-block\">Subscribe For more educational videos!<\/span>\n          <span class=\"channel-name\">Hostinger Academy<\/span>\n        <\/div>\n      <\/div>\n      <div class=\"col-5 col-sm-4 d-flex align-items-center justify-content-end\">\n          <a data-click-id=\"hgr-post-content-link-subscribe\" class=\"subscribe-button\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"http:\/\/www.youtube.com\/channel\/UCbNIC-svDbtUOH2qsLnPQPg?sub_confirmation=1\">\n            <img decoding=\"async\" src=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/themes\/tutorialsthemeuplift\/public\/images\/icons\/youtube.svg\" alt=\"subscribe\">\n            <span>Subscribe<\/span>\n          <\/a>\n      <\/div>\n    <\/div>\n  <\/div>\n\n    \n\n\n\n<\/p><h2 id=\"h-how-to-fix-the-502-bad-gateway-error\" class=\"wp-block-heading h-t-title-2\">How to fix the 502 Bad Gateway error as a visitor<\/h2><p class=\"wp-block-paragraph\">To fix a 502 Bad Gateway error as a visitor, reload the page and check whether the site is down for others. If it&rsquo;s working for them, clear your browser cache, try a private window, flush your DNS cache, or test on another device.<\/p><h3 id=\"h-1-refresh-the-page\" class=\"wp-block-heading h-t-title-3\">1. Refresh the page<\/h3><p class=\"wp-block-paragraph\">A 502 Bad Gateway error is usually temporary, stemming from a sudden traffic surge. A quick refresh can resolve the issue.<\/p><p class=\"wp-block-paragraph\">On Windows, press <strong>F5<\/strong> or <strong>CTRL + F5.<\/strong> On Mac, use <strong>CMD + R<\/strong>.<\/p><h3 id=\"h-2-check-the-site-status\" class=\"wp-block-heading h-t-title-3\">2. Check the site status<\/h3><p class=\"wp-block-paragraph\">If the 502 error code is still showing, it is possible that the website&rsquo;s server might be experiencing downtime.<\/p><p class=\"wp-block-paragraph\">Luckily, there are many tools to identify whether a site is actually down, including&nbsp;<a data-click-id=\"hgr-post-content-link-down-for-everyone-or-just-me\" href=\"https:\/\/downforeveryoneorjustme.com\/\" target=\"_blank\" rel=\"noopener\">Down for Everyone or Just Me<\/a>&nbsp;and&nbsp;<a data-click-id=\"hgr-post-content-link-isitdownrightnow\" href=\"https:\/\/www.isitdownrightnow.com\/\" target=\"_blank\" rel=\"noopener\">IsItDownRightNow<\/a>. Simply input the URL to check the website&rsquo;s status.<\/p><h3 id=\"h-3-clear-your-browser-cache\" class=\"wp-block-heading h-t-title-3\">3. Clear your browser cache<\/h3><p class=\"wp-block-paragraph\">If the site works for others but you still see a 502, your browser may be showing a cached error page. Clear your browser&rsquo;s cached files by selecting <strong>Cached images and files<\/strong> if your browser offers that option. Then reload the page that showed the error.<\/p><p class=\"wp-block-paragraph\">Keep in mind that removing cached files might result in losing important browser data, including bookmarks and settings preferences. To prevent this, export your data from the browser and import it back afterwards.<\/p><h3 id=\"h-4-try-in-incognito-mode\" class=\"wp-block-heading h-t-title-3\">4. Try in Incognito mode<\/h3><p class=\"wp-block-paragraph\">Access the website in Incognito or private mode to determine whether the 502 gateway timeout appears due to a browser-related issue. To open an Incognito window in Chrome, click on the three-dots button on your browser screen and choose <strong>New Incognito Window<\/strong>.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2024-03-chrome-new-i\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/03\/chrome-new-incognito-window-highlighted.png\"><img decoding=\"async\" width=\"1024\" height=\"574\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/45\/2024\/03\/chrome-new-incognito-window-highlighted.png\/w=1024,h=1024,fit=scale-down\" alt=\"New incognito window option highlighted in Chrome\" class=\"wp-image-106504\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/45\/2024\/03\/chrome-new-incognito-window-highlighted.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/45\/2024\/03\/chrome-new-incognito-window-highlighted.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/45\/2024\/03\/chrome-new-incognito-window-highlighted.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/45\/2024\/03\/chrome-new-incognito-window-highlighted.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\">If the error doesn&rsquo;t occur in Incognito mode, a browser extension is likely causing the problem.<\/p><p class=\"wp-block-paragraph\">Try to disable your add-ons or extensions one by one. Once you&rsquo;ve disabled the extension causing the error, you should be able to access the website. From our experience, an ad-blocker extension is usually the culprit.<\/p><p class=\"wp-block-paragraph\">If disabling browser extensions doesn&rsquo;t help, try a different browser. For example, if you&rsquo;re currently on Google Chrome, try using Mozilla Firefox.<\/p><p class=\"wp-block-paragraph\">If the page works on the new browser, your previous browser might be causing the error. To solve the problem, try deleting and reinstalling your faulty browser.<\/p><h3 id=\"h-5-flush-the-dns-cache\" class=\"wp-block-heading h-t-title-3\">5. Flush the DNS cache<\/h3><p class=\"wp-block-paragraph\">Other common causes of 502 Bad Gateway are DNS problems, such as incorrect IP addresses and unresponsive DNS servers.<\/p><p class=\"wp-block-paragraph\">In this case, <a data-click-id=\"hgr-post-content-link-flushing-your-dns-cache\" href=\"\/my\/tutorials\/how-to-flush-dns\/\">flushing your DNS cache<\/a> can be the answer. This method works similarly to clearing your browser&rsquo;s cache. It will remove faulty IP entries from your DNS cache.<\/p><p class=\"wp-block-paragraph\">Consider also temporarily or permanently changing your DNS servers. Your ISP assigns your DNS servers by default. However, you can always change them to a third-party server, such as <a data-click-id=\"hgr-post-content-link-google-public-dns\" href=\"https:\/\/developers.google.com\/speed\/public-dns\/\" target=\"_blank\" rel=\"noopener\">Google Public DNS<\/a>.<\/p><h3 id=\"h-6-test-on-another-device\" class=\"wp-block-heading h-t-title-3\">6. Test on another device<\/h3><p class=\"wp-block-paragraph\">If none of the above 502 error fixes work, test your internet connection on another computer or a mobile device, ideally connected to a different network.<\/p><p class=\"wp-block-paragraph\">Additionally, try restarting your computer and router. This will show whether the error is related to your networking equipment or if the problem lies elsewhere.<\/p><h2 class=\"wp-block-heading h-t-title-2\" id=\"h-how-to-fix-the-502-bad-gateway-error-as-a-website-owner\">How to fix the 502 Bad Gateway error as a website owner<\/h2><p class=\"wp-block-paragraph\">To fix a 502 Bad Gateway error on your website, start by checking the error logs. Use what you find to narrow down the cause, whether it&rsquo;s a plugin or theme, your CDN, a PHP timeout, or the server or application behind your proxy.<\/p><h3 id=\"h-7-check-error-logs\" class=\"wp-block-heading h-t-title-3\">7. Check error logs<\/h3><p class=\"wp-block-paragraph\">If you encounter a 502 error on a website after a change or an update, you might be dealing with a web server error. The best approach to solving this issue is to <a data-click-id=\"hgr-post-content-link-check-your-website-error-log\" href=\"\/my\/tutorials\/how-to-check-your-website-error-log\/\">check your website error log<\/a>.<\/p><p class=\"wp-block-paragraph\">Usually, your <a data-click-id=\"hgr-post-content-link-hosting-service\" href=\"\/my\/web-hosting\">hosting service<\/a> lets you access your website&rsquo;s error log files through an admin dashboard. You can also enable error logging on your WordPress website by adding the following lines in <strong>wp-config.php<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">define( 'WP_DEBUG', true ); \ndefine( 'WP_DEBUG_LOG', true ); \ndefine( 'WP_DEBUG_DISPLAY', false );<\/pre><p class=\"wp-block-paragraph\">After enabling debug logging, reload the page that showed the 502 error. Then open <code>wp-content\/debug.log<\/code> and look for entries recorded around the time of your test. If the WordPress log has no relevant entries, check your hosting or web server error logs. Turn off WordPress debugging when you finish.<\/p><h3 id=\"h-8-check-plugins-and-themes\" class=\"wp-block-heading h-t-title-3\">8. Check plugins and themes<\/h3><p class=\"wp-block-paragraph\">Sometimes, faulty plugins or themes can cause the error.<\/p><p class=\"wp-block-paragraph\">This is because poorly coded plugins and themes can conflict with each other. When this happens, your server will stop every script and query on your website, making it inaccessible.<\/p><p class=\"wp-block-paragraph\">For some websites, the issue usually comes from caching or security plugins. There is a good chance that these plugins block communication between servers, causing the error to persist.<\/p><p class=\"wp-block-paragraph\">If you don&rsquo;t have a caching or security plugin installed but still encounter the HTTP 502 error, it&rsquo;s best to disable your plugins and re-activate them one by one. To do so, go to <strong>Plugins<\/strong> and click <strong>Deactivate<\/strong> from the <strong>Bulk Actions<\/strong> menu.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-wordpress-pl\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/wordpress-plugins-deactivate.png\"><img decoding=\"async\" width=\"1972\" height=\"864\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/wordpress-plugins-deactivate.png\/w=1024,h=1024,fit=scale-down\" alt=\"Plugins menu in WordPress with deactivate section highlighted\" class=\"wp-image-31476\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate.png 1972w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate-300x131.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate-1024x449.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate-150x66.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate-768x336.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/wordpress-plugins-deactivate-1536x673.png 1536w\" sizes=\"(max-width: 1972px) 100vw, 1972px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\">Then, activate each plugin while refreshing your WordPress site after each one. Once the 502 error pops up again, you will find the problem plugin.<\/p><p class=\"wp-block-paragraph\">However, if you can&rsquo;t access your WordPress dashboard, you can try disabling them from your hosting panel or FTP program. Navigate to the <strong>wp-content<\/strong> directory and rename the plugins directory, for example, <strong>plugins-disable<\/strong>.<\/p><p class=\"wp-block-paragraph\">Or, if you use Hostinger, access your <strong>Hostinger dashboard<\/strong> and click on <strong>Files<\/strong>. From there, go to <strong>File Manager &rarr; public_html &rarr; wp-content. <\/strong><\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2023-03-filemanager\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/filemanager-publichtml-wpcontent-plugins-rename.png\"><img decoding=\"async\" width=\"599\" height=\"366\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/03\/filemanager-publichtml-wpcontent-plugins-rename.png\/public\" alt=\"Plugin rename pop up close up in File Manager\" class=\"wp-image-80669\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/03\/filemanager-publichtml-wpcontent-plugins-rename.png 599w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/03\/filemanager-publichtml-wpcontent-plugins-rename-300x183.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/03\/filemanager-publichtml-wpcontent-plugins-rename-150x92.png 150w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\">If your site starts working after all plugins are disabled, rename the folder back to <strong>plugins<\/strong>. Then, try enabling the plugins one by one to determine which one caused the error in the first place.<\/p><p class=\"wp-block-paragraph\">If the website still doesn&rsquo;t work, and you&rsquo;re using a custom, premium, or child theme, try activating one of the default WordPress themes. Simply go to <strong>Appearance<\/strong> <strong>&rarr;<\/strong> <strong>Themes<\/strong>, click <strong>Add Theme<\/strong>, find one of the WordPress default themes you don&rsquo;t already have installed, like <strong>Twenty Twenty-Five<\/strong>, then click <strong>Install<\/strong>. Wait a few seconds, then click the <strong>Activate<\/strong> button once it is available.<\/p><p class=\"wp-block-paragraph\">Check to see if the problem persists. If it does, it isn&rsquo;t related to the site&rsquo;s theme, so you can safely re-activate the theme you were using previously.<\/p><h3 id=\"h-9-check-your-content-delivery-network-cdn\" class=\"wp-block-heading h-t-title-3\">9. Check your content delivery network (CDN)<\/h3><p class=\"wp-block-paragraph\">Issues with your&nbsp;<a data-click-id=\"hgr-post-content-link-content-delivery-network-cdn\" href=\"\/my\/tutorials\/what-is-cdn\/\" target=\"_blank\" rel=\"noopener\">content delivery network (CDN)<\/a> or <strong>DDoS<\/strong> mitigation services can also cause 502 Bad Gateway errors.<\/p><p class=\"wp-block-paragraph\">A CDN adds an extra layer between your server and browser to deliver web content efficiently. However, this layer can run into an issue when connecting with your origin server, resulting in 502 Errors.<\/p><p class=\"wp-block-paragraph\">One notable example is <strong>Cloudflare<\/strong>, where the 502 Bad Gateway can occur in two different variations depending on the issue.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-cloudflare-n\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/cloudflare-nginx-502.png\"><img decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/cloudflare-nginx-502.png\/w=1024,h=1024,fit=scale-down\" alt=\"Cloudflare bad gateway error\" class=\"wp-image-31470\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/cloudflare-nginx-502.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/cloudflare-nginx-502-300x153.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/cloudflare-nginx-502-150x77.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/cloudflare-nginx-502-768x392.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/cloudflare-nginx-502-1536x785.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\">The screen above indicates that the issue is on Cloudflare&rsquo;s side. To fix it, you&rsquo;ll need to reach out to their customer support team. Remember to check the <a data-click-id=\"hgr-post-content-link-cloudflare-system-status\" href=\"https:\/\/www.cloudflarestatus.com\/\" target=\"_blank\" rel=\"noopener\">Cloudflare System Status<\/a> page before doing so.<\/p><p class=\"wp-block-paragraph\">Alternatively, you can disable Cloudflare. However, keep in mind that your DNS propagation may take a couple of hours.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-502-error-ba\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/502-error-bad-gateway.png\"><img decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/502-error-bad-gateway.png\/w=1024,h=1024,fit=scale-down\" alt=\"502 error resulting from web hosting side\" class=\"wp-image-31468\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/502-error-bad-gateway.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/502-error-bad-gateway-300x153.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/502-error-bad-gateway-150x77.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/502-error-bad-gateway-768x392.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/502-error-bad-gateway-1536x785.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\">If you see the Cloudflare error shown above, it means that the issue is with your current web hosting provider. In this case, try contacting your web host support team for assistance.<\/p><h3 id=\"h-10-increase-php-max-execution-time-and-max-input-time\" class=\"wp-block-heading h-t-title-3\">10. Investigate PHP timeouts<\/h3><p class=\"wp-block-paragraph\">If your logs show a PHP timeout, note which page or action triggered it. If the error started after a plugin update or code change, investigate that change first.<\/p><p class=\"wp-block-paragraph\">If a task such as a large import legitimately needs more time and the log shows that PHP reached its maximum execution time, check the current <code>max_execution_time<\/code> setting. If you use managed hosting, ask your provider whether you can increase it. After making a change, retry the same task to see whether the error returns.<\/p><figure class=\"wp-block-image size-full\"><a data-click-id=\"hgr-post-content-link-my-web-hosting\" href=\"\/my\/web-hosting\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/public\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-300x88.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-150x44.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2023\/11\/Web-hosting_in-text-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading h-t-title-3\">11. Check the service behind your proxy<\/h3><p class=\"wp-block-paragraph\">Check that the application behind your proxy is running and listening where the proxy expects it. If you use Nginx, verify that <code>proxy_pass<\/code> points to the correct application address and port. If Nginx sends PHP requests to PHP-FPM, check that <code>fastcgi_pass<\/code> matches the PHP-FPM pool&rsquo;s <code>listen<\/code> address or socket.<\/p><p class=\"wp-block-paragraph\">If PHP-FPM has stopped, check its logs for the cause before restarting it. Then reload the URL that showed the 502 error.<\/p><p class=\"wp-block-paragraph\">If your hosting provider manages the server, send them the affected URL, the time and time zone when the error occurred, and any relevant log entries. Ask them to check whether the proxy can reach the application.<\/p><h2 id=\"h-502-bad-gateway-error-variations\" class=\"wp-block-heading h-t-title-2\">502 Bad Gateway error variations<\/h2><p class=\"wp-block-paragraph\">A 502 error can appear on any device or service, but the exact message might differ. Here are some variations of this HTTP status code you might see:<\/p><ul class=\"wp-block-list\">\n<li><strong>Simple<\/strong> &ndash; Temporary Error (502), 502 Error.<\/li>\n\n\n\n<li><strong>Descriptive<\/strong> &ndash; HTTP Error 502 Bad Gateway, 502 Server Error, with an explanation.<\/li>\n\n\n\n<li><strong>Technical<\/strong> &ndash; 502 Web server received an invalid response, HTTP 502, 502 Proxy Error.<\/li>\n\n\n\n<li><strong>Overload<\/strong> &ndash; 502 Service Temporarily Overloaded.<\/li>\n\n\n\n<li><strong>Server-specific<\/strong> &ndash; 502 Bad Gateway Nginx, depending on server software.<\/li>\n\n\n\n<li><strong>Blank screen<\/strong> &ndash; some websites show a plain white screen.<\/li>\n<\/ul><p class=\"wp-block-paragraph\">Some browsers, websites, or platforms offer up unique error pages with additional information. For instance, <strong>Chrome<\/strong> offers troubleshooting tips and suggests retrying.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-google-502-e\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/google-502-error.png\"><img decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/google-502-error.png\/w=1024,h=1024,fit=scale-down\" alt=\"Chrome 502 error page\" class=\"wp-image-31472\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/google-502-error.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/google-502-error-300x153.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/google-502-error-150x77.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/google-502-error-768x392.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/google-502-error-1536x785.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\"><strong>GitLab<\/strong> explains the communication issue and provides solutions.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-gitlab-502-e\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/gitlab-502-error.png\"><img decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/gitlab-502-error.png\/w=1024,h=1024,fit=scale-down\" alt=\"Gitlab 502 error page\" class=\"wp-image-31471\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/gitlab-502-error.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/gitlab-502-error-300x153.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/gitlab-502-error-150x77.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/gitlab-502-error-768x392.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/gitlab-502-error-1536x785.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p class=\"wp-block-paragraph\"><strong>X (previously Twitter)<\/strong>, on the other hand, displays a friendly message with an illustration.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a data-click-id=\"hgr-post-content-link-my-tutorials-wp-content-uploads-sites-2-2018-04-twitter-502\" href=\"\/my\/tutorials\/wp-content\/uploads\/sites\/2\/2018\/04\/twitter-502-error.png\"><img decoding=\"async\" width=\"1024\" height=\"523\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2018\/04\/twitter-502-error.png\/w=1024,h=1024,fit=scale-down\" alt=\"Twitter\/X 502 error page\" class=\"wp-image-31475\" srcset=\"https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/twitter-502-error.png 1024w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/twitter-502-error-300x153.png 300w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/twitter-502-error-150x77.png 150w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/twitter-502-error-768x392.png 768w, https:\/\/www.hostinger.com\/my\/tutorials\/wp-content\/uploads\/sites\/45\/2018\/04\/twitter-502-error-1536x785.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Improve your user experience with customized error pages                <\/p>\n            <\/div>\n            <p class=\"protip__content\">We recommend <a data-click-id=\"hgr-post-content-link-customizing-your-pages-with-error-codes\" href=\"https:\/\/support.hostinger.com\/en\/articles\/1583295-how-to-customize-your-website-s-error-pages\" target=\"_blank\" rel=\"noopener\">customizing your pages with error codes<\/a>. This way, you can improve your user experience by providing helpful content for your visitors. <\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h2 id=\"h-is-a-502-bad-gateway-permanent\" class=\"wp-block-heading h-t-title-2\">Is a 502 Bad Gateway permanent?<\/h2><p class=\"wp-block-paragraph\">A 502 Bad Gateway error is usually not a permanent website failure. Most of these errors clear up on their own within minutes, or you can fix them quickly by refreshing the page, clearing your cache, or trying one of the other solutions we covered.<\/p><h2 class=\"wp-block-heading h-t-title-2\" id=\"h-does-a-502-bad-gateway-error-affect-seo\"><strong>Does a 502 Bad Gateway error affect SEO?<\/strong><\/h2><p class=\"wp-block-paragraph\">While 502 errors are temporary, they can hurt your search engine rankings if they stick around too long.<\/p><p class=\"wp-block-paragraph\">Search engines like Google want to give users a good experience, so pages that are frequently inaccessible due to server errors can see their rankings drop. Learn more about the many factors that influence your rankings in our <a data-click-id=\"hgr-post-content-link-seo-guide\" href=\"\/my\/tutorials\/what-is-seo\/\">SEO guide<\/a>.<\/p><h2 class=\"wp-block-heading h-t-title-2\" id=\"h-how-can-you-catch-recurring-502-errors\">How can you catch recurring 502 errors?<\/h2><p class=\"wp-block-paragraph\">Once your site is working again, set up <a data-click-id=\"hgr-post-content-link-uptime-alerts-for-the-affected-url\" href=\"\/my\/tutorials\/how-to-monitor-uptime-and-downtime\/\" data-type=\"link\" data-id=\"\/tutorials\/how-to-monitor-uptime-and-downtime\/\">uptime alerts for the affected URL<\/a>. Monitor both your homepage and the page that returned the error. Your homepage may load normally while a specific page or feature still fails.<\/p><p class=\"wp-block-paragraph\">If a 502 returns, note the affected URL and the time it started. Compare the alert with your web server and application logs, CPU and memory usage, and any recent deployments or updates. A 502 that affects several pages during a traffic spike gives you a reason to check for resource limits. If it consistently affects one page or action, start with the application handling that request.<\/p><p class=\"wp-block-paragraph\">After you make a fix, keep monitoring the affected URL through the conditions that originally triggered the error. If the 502 appeared during peak traffic, for example, check whether the page stays available during the next busy period.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A 502 Bad Gateway error occurs when a server acting as a gateway or proxy receives an invalid response from the upstream server. Common causes include an overloaded server, a problem with the application behind the proxy, or an incorrect proxy setting. If you&rsquo;re visiting the site, reload the page and check whether it&rsquo;s down [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/my\/tutorials\/how-to-fix-502-bad-gateway-error-2\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":180,"featured_media":135201,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"502 Bad Gateway error: What it is and how to fix it","rank_math_description":"Learn how to fix 502 Bad Gateway errors quickly with our step-by-step guide, covering simple browser refreshes to server troubleshooting.","rank_math_focus_keyword":"502 bad gateway","_content_updated_date":"2025-07-09","footnotes":""},"categories":[22708],"tags":[],"class_list":["post-8060","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-aspects"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/corrigir-erro-502-bad-gateway\/","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/erreur-502-bad-gateway\/","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/solucionar-error-502-bad-gateway\/","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/502-bad-gateway\/","default":0},{"locale":"de-DE","link":"https:\/\/www.hostinger.com\/de\/tutorials\/502-bad-gateway\/","default":0},{"locale":"it-IT","link":"https:\/\/www.hostinger.com\/it\/tutorial\/errore-502-bad-gateway\/","default":0},{"locale":"nl-NL","link":"https:\/\/www.hostinger.com\/nl\/tutorials\/502-bad-gateway\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-fix-502-bad-gateway-error-2","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-fix-502-bad-gateway-error-2","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-fix-502-bad-gateway-error","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/solucionar-error-502-bad-gateway\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/solucionar-error-502-bad-gateway\/","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/solucionar-error-502-bad-gateway\/","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/corrigir-erro-502-bad-gateway\/","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/8060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/users\/180"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/comments?post=8060"}],"version-history":[{"count":81,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/8060\/revisions"}],"predecessor-version":[{"id":138543,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/posts\/8060\/revisions\/138543"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/media\/135201"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/media?parent=8060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/categories?post=8060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/my\/tutorials\/wp-json\/wp\/v2\/tags?post=8060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}