502 Bad Gateway Checklist for Nginx PHP-FPM

halfbrain_logo512adminJune 12, 2026
169 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.

Checklist Type Troubleshooting
Level Intermediate
Risk Level High Risk
Estimated Time 30–60 minutes

When to Use This Checklist

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

Required Tools

SSH access, Nginx, PHP-FPM, server block config, Nginx error log, PHP-FPM log, VPS access

Structured Checklist Steps

  1. Check whether all PHP pages are affected.
  2. Run nginx -t.
  3. Check Nginx status.
  4. Check PHP-FPM status.
  5. Verify fastcgi_pass socket path.
  6. Check RAM and CPU.
  7. Read Nginx error log.
  8. Read PHP-FPM log.
  9. Restart PHP-FPM if needed.
  10. Reload Nginx after config fix.

Verification Steps

  1. Open homepage.
  2. Open wp-admin if this is WordPress.
  3. Run nginx -t again.
  4. Confirm error log has no new upstream errors.
  5. Check PHP-FPM remains active.

Rollback Plan

If a config edit caused the 502 error, restore the previous Nginx server block or PHP-FPM pool config, then reload Nginx and restart PHP-FPM.

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

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 *