502 Bad Gateway Checklist for Nginx PHP-FPM

halfbrain_logo512adminJune 12, 2026
1 lượt xem

502 Bad Gateway Checklist for Nginx PHP-FPM

A 502 Bad Gateway error usually means Nginx cannot communicate properly with the backend service. On WordPress or PHP websites, the backend is often PHP-FPM. This checklist helps you check Nginx, PHP-FPM, socket configuration, service status, logs and server resources in the correct order.

Common causes

  • PHP-FPM is stopped.
  • PHP-FPM socket path is wrong.
  • Nginx server block points to the wrong backend.
  • PHP-FPM is overloaded.
  • RAM is exhausted.
  • Recent PHP or Nginx config changes broke the site.

Checklist

  1. Confirm whether the error affects the whole website or only PHP pages.
  2. Run nginx -t to validate Nginx config.
  3. Check Nginx service status.
  4. Check PHP-FPM service status.
  5. Verify the PHP-FPM socket or upstream address in the Nginx config.
  6. Check RAM and CPU usage.
  7. Read Nginx error log.
  8. Read PHP-FPM log if available.
  9. Restart PHP-FPM only if it is failing.
  10. Reload Nginx after fixing config.

Final check

A 502 error should not be fixed by random restarts. The correct fix is to identify whether Nginx, PHP-FPM, socket path, permissions or server resources caused the failure.

Estimated Time

30–60 minutes

Use Case

Use this checklist when a WordPress or PHP website behind Nginx returns a 502 Bad Gateway error.


Common Mistakes

  • Restarting Nginx without checking PHP-FPM.
  • Using the wrong PHP socket path.
  • Editing multiple configs at once.
  • Ignoring RAM exhaustion.
  • Forgetting to run nginx -t before reload.

Related Commands

sudo nginx -t
sudo systemctl status nginx
sudo systemctl status php8.2-fpm
sudo tail -n 100 /var/log/nginx/error.log
free -h
df -h
sudo systemctl restart php8.2-fpm
sudo systemctl reload nginx
See also  Nginx Access Log Analysis Checklist for Bot Traffic

Share:

Disclaimer: The guides, checklists, commands, and examples on HalfBrain.net are provided for educational and operational reference only. Server environments, hosting providers, software versions, security settings, and WordPress configurations can vary, so you should always review commands before running them on your own system. We do our best to keep the content accurate and useful, but we cannot guarantee that every command, configuration, or recommendation will fit every environment. Always back up your website, database, and server configuration before making changes. HalfBrain.net is not responsible for data loss, downtime, security incidents, misconfiguration, or other issues that may result from applying the information on this website. Use the material at your own discretion.

Leave a Reply

Your email address will not be published. Required fields are marked *