When you get a 502 Bad Gateway error, it means that something is wrong with the server or your Internet connection. A 502 Bad Gateway error can indicate either one of these problems, so in order to fix it you’ll need to check both the server and your Internet connection to ensure they are functioning properly. Follow the steps below to resolve this issue
1) Do NOT Panic
How do I fix 502 Bad gateway? The most important thing is that you don’t panic. No one likes getting an error message, but if you act immediately, you can often fix it yourself. If not, find an expert and start telling them about it now. You want to get into that headspace of letting go and having someone else deal with it. Making things worse can be done easily when you’re in fixer-upper mode, so don’t fall into that trap – leave fixing for experts.
2) Check your server settings
How do I fix 502 Bad gateway? Typically, you’ll run into problems with your server’s settings. To make sure everything is in working order, log into your server and look for errors in your Apache or Nginx logs. Check common configuration issues such as HTTP vs HTTPS URLs, invalid (or non-existent) URLs/domains/subdomains, empty pages, connection timing out after one second, Nginx cache issues, PHP errors from WordPress and eCommerce store software — anything that seems unusual. If all looks good but you still can’t figure out what’s wrong on your end—it might be time to check with your hosting provider!
3) Restart Apache/Nginx
Sometimes, even after checking for server errors and correcting any code issues, 502 bad gateway errors can still occur. If that’s what you’re facing, restarting your Apache or Nginx process should clear up any problems. After all, while there may be some issue with your code that is causing the problem, it’s just as likely there are deeper-rooted problems with your server (which restarting can fix). Once you’ve restarted Apache/Nginx, monitor it closely and check for errors again over time. (see tips below) You’ll also want to make sure no other files have been removed in error or modified by malicious users. (ref: How do I fix 502 Bad gateway?)
4) Check Your PHP Configuration Files
If you’re getting a 502 error and are running Apache as your web server, check your server’s PHP configuration files. Look for any directives that might restrict script execution time or memory usage; it may be causing scripts to execute slowly or with limited functionality. Changing these settings can result in an instant fix for your problem, but be careful because some of these settings (like max_execution_time) may affect more than just your website. If you’re not sure what you’re doing, ask someone who does.
5) Scan the Web Server for Malware
Running a virus scan on your computer may take care of 502 Bad gateway errors, because bad guys sometimes hijack innocent sites and use them as fronts for hosting malware. Make sure your computers are free of spyware or adware before continuing with your research. How do I fix 502 Bad gateway? Follow these five tips to fix an error on page not found for more information about dealing with malware and other site problems.
Once you’ve completed basic maintenance on your computers, it’s time to look at server-side issues. Many website owners—even highly qualified professionals—don’t realize that running WordPress without proper settings can allow hackers to access their systems through attacks called cross-site scripting (XSS) attacks. How do I fix 502 Bad gateway? Learn how here…