There are several causes of the 502 bad gateway error, so there are multiple ways to fix it. We will focus on the most popular here.
First, try to restart the server. Sometimes, servers get stuck; a simple restart can fix the issue.
If that didn’t help, please review the WordPress error.log file to discover the root cause. Add the code below to the wp-config.php file to enable troubleshooting and start debugging.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Then, follow the steps below to fix the 502 bad gateway error:
- Turn off all plugins
Access your cPanel and change the wp-content/plugins folder name to pluginsDISABLE. That will turn off all the plugins on your website.
- Switch to the default theme.
Navigate to the Themes folder and switch to the default theme by renaming the current theme.
- Test if the problem was solved.
Refresh your website. If the website is working now, the 502 bad gateway error was caused by the theme or one of the plugins. You’ll need to find which one.
- Find the faulty plugin.
Start activating the plugins individually to discover which plugin caused the issue.
- Fix the problematic plugin.
Once you find the problematic plugin, deactivate or update it to its latest version.
Other possible fixes can be:
- Upgrade your host plan to a better one with more resources.
- Disable CDN or proxy services such as Cloudflare.
- Ensure the DNS records are pointing to the correct server address.
- Make sure the database is well-configured and accessible.
We love fixing the 502 Bad Gateway error and look forward to fixing it for you.
502 bad gateway – frequently asked questions
Multiple causes of the 502 bad gateway error in WordPress can occur, such as poor coding, a lack of resources on the server, a stuck server, poor DNS configuration, and more.
There are several ways to fix it, but first, you’ll need to enable debug mode to find the root cause of the issue.
In most cases, a faulty plugin or theme is the cause. Therefore, deactivate all plugins and reactivate them individually until you find the plugin that triggers the issue. Then, deactivate it or update it.
Yes. This can happen when the server is overwhelmed with requests, runs out of memory or disk space, experiences downtime, or is undergoing maintenance.
Misconfigured or poorly coded plugins or a malfunctioning core system file can trigger the 502 bad gateway error.
Yes. The 502 bad gateway error mainly occurs on the server side, so misconfigured server settings can trigger the issue.
Yes, we would love to. We specialize in fixing the 502 bad gateway error and can do so in the next few hours.


