A 502 error is usually displayed if a single PHP process runs for longer than the max_execution_time or max_input_time set in the PHP configuration, causing a PHP timeout to occur.

You’ll first need to determine what’s causing the 502 error to find a solution. You may need to increase resources, adjust settings, or find an alternative workflow in some cases.

For instance, if the error occurs when you’re attempting an import, running the import directly on the container using WP-CLI or a local PHP or Bash script is a recommended alternative.

Finding and Resolving a 502 Bad Gateway Error

There may be a number of places to check and solutions to try when hunting down the source of a 502 Bad Gateway Error.

Third-Party CDN

If your site uses a third-party CDN in addition to Kinsta’s Cloudflare integration, temporarily disable or bypass that CDN. If the issue is resolved, you’ll need to adjust settings or check with your CDN provider’s support to see if a firewall or other feature is interfering with your site.

Error Log

Check the error.log for your site in MyKinsta (or download via SFTP) to narrow down the source of the error. If nothing obvious stands out, it may be helpful to enable WP-DEBUG.

MyKinsta Analytics

View the 500 error breakdown report in MyKinsta Analytics to see the total number of 502 errors and when they occur.

Plugins and Themes

Deactivate all plugins and switch to a default theme. If the issue is resolved, reactivate plugins one by one and reactivate your theme until the issue reoccurs. Once you’ve determined which plugin or theme is the source, send a copy of the error to the plugin or theme developer so they can help you resolve the issue.

Request PHP Timeout Increase

Here at Kinsta, the max_execution_time or max_input_time values are set to 300 seconds (5 minutes) by default. The maximum PHP timeout values available are based on your current hosting plan. If you need these increased, start a new chat with our Support team.

Increase Number of PHP Workers

In some cases, more PHP workers may be needed. If you’re not sure, our Support team can help you determine if adding more PHP workers is needed for your site.