Nginx 504 Gateway Timeout Deep Diagnosis Checklist

halfbrain_logo512adminJune 19, 2026
10 lượt xem

Nginx 504 Gateway Timeout Deep Diagnosis Checklist

Nginx 504 Gateway Timeout means the upstream service did not respond in time. The backend may be slow, overloaded, blocked by database queries, stuck in PHP execution or waiting for an external API.

Core principle

504 is a time problem. Nginx can reach the backend, but the backend cannot finish the work fast enough.

Checklist

  1. Identify the URL or action causing timeout.
  2. Check whether all pages timeout or only specific actions.
  3. Check Nginx error log for upstream timeout messages.
  4. Check PHP-FPM or backend logs.
  5. Check CPU, RAM and disk pressure.
  6. Check MySQL load or slow queries.
  7. Check long-running imports, backups or cron jobs.
  8. Check external API calls if the app depends on them.
  9. Increase timeout only after understanding the root cause.
  10. Verify response time after mitigation.

Reusable lesson

This applies to WordPress imports, WooCommerce checkout, heavy admin pages, APIs, n8n workflows, crawlers and automation endpoints.

Checklist Type Troubleshooting
Level Intermediate
Risk Level High Risk
Estimated Time 45–120 minutes

When to Use This Checklist

Use this checklist when Nginx returns 504 during WordPress actions, imports, admin pages, APIs, webhooks or automation workflows.

Required Tools

SSH access, Nginx logs, PHP-FPM logs, MySQL access, server monitoring, affected URL or action

Before You Start

Do not simply raise timeouts. First find why the backend takes too long.

Verification Steps

  1. Timeout source is identified.
  2. Backend pressure is reduced or explained.
  3. Logs no longer show repeated timeout.
  4. Critical URL responds within acceptable time.
  5. Timeout changes are documented if used.

Rollback Plan

If timeout tuning hides the symptom but server pressure remains, restore safe timeout values and fix the slow backend operation in smaller batches.

Common Mistakes

  • Increasing timeouts blindly.
  • Ignoring database load.
  • Running heavy imports during traffic.
  • Not checking PHP-FPM workers.
  • Confusing 504 with network DNS issue.

Related Commands

curl -w "%{time_total}
" -o /dev/null -s https://example.com
sudo tail -n 100 /var/log/nginx/error.log
sudo systemctl status php8.2-fpm
top
free -h
mysqladmin -u root -p processlist
crontab -l

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 *