انتقل إلى المحتوى

الدروس استكشاف الأخطاء وإصلاحها متوسط1 دقائق قراءة

How to Fix a 504 Gateway Timeout Error

A 504 Gateway Timeout means an upstream server took too long to answer. Learn to find slow scripts, database queries and proxy timeouts behind it.

بواسطة فريق تحرير ZSOLNET آخر تحديث

هذه الصفحة غير متاحة بالعربية بعد، لذا تُعرض بالإنجليزية.

أهم النقاط

  • A 504 means something upstream is slow, usually a database query or external API.
  • Bypass the CDN to tell whether the origin is at fault.
  • Fix slow code and add caching before raising timeouts.

A 504 Gateway Timeout is returned by a proxy, CDN or web server when the server behind it doesn’t respond within the allowed time. Something is slow, not broken — and the fix is to find what.

Find the slow layer

  1. Reproduce it. Note which URLs time out. If it’s every page, suspect the server or database; if it’s one page, suspect that page’s code.
  2. Bypass the CDN. If the origin also hangs, the problem is on your server. If the origin is fast, check the CDN’s connection to your origin.
  3. Check the database. Slow queries are the most common cause. On WordPress, a plugin like Query Monitor shows queries per page; on a VPS, enable MySQL’s slow query log.
  4. Check external calls. Code that waits for a third-party API, payment gateway or font server can hang until the timeout.

Fix the cause, then the timeout

  • Optimise or index slow queries, and remove plugins that run heavy queries on every page load.
  • Move long jobs (imports, exports, image processing) to background tasks or cron jobs.
  • Add page and object caching so most requests skip the slow path.

Only after that, if a legitimate request genuinely needs longer, raise the timeouts consistently across layers (for example Nginx proxy_read_timeout and PHP max_execution_time). Raising timeouts alone just makes visitors wait longer.

شارك X LinkedIn Facebook

الدخول إلى حسابك

أدِر نطاقاتك واستضافتك وفواتيرك من مكان واحد.

اتصال آمن مباشرة مع منطقة العملاء في ZSOLNET.

ليس لديك حساب؟