Home › Knowledgebase › KB-1307

Why is my website showing a 504 gateway timeout error?

Summary

This guide helps you troubleshoot and resolve: Why is my website showing a 504 gateway timeout error?. Follow the steps below to fix the issue.

Quick Tip: Need immediate assistance? 💻 Open a Ticket

Common Causes

A 504 Gateway Timeout error occurs when a server acting as a gateway or proxy does not receive a timely response from an upstream server. Essentially, the server your browser is connecting to is waiting for another server to complete a task, but that task takes too long to finish. This results in the connection timing out and the error page being displayed to the visitor.

Important: A 504 Gateway Timeout error is typically server-side. Refreshing the page will not resolve a persistent upstream issue, as the delay is occurring between servers rather than within your local browser or network.

Quick Fix Steps

  1. Refresh your browser page by pressing F5 or Ctrl + R on Windows, or Command + R on macOS. If the error persists, it indicates a server-side issue.
  2. Wait a few minutes and try accessing the website again. Temporary network interruptions often resolve themselves.
  3. Clear your browser cache to ensure you are not loading a cached error page.
  4. Try accessing the website from a different device or network to rule out local connectivity issues.

Detailed Instructions

Check for Resource-Heavy Scripts

If your website runs complex scripts or large database queries, the upstream server may exceed the allowed execution time. This is frequently caused by the max_execution_time setting in PHP or gateway/proxy timeout configurations.

  1. Log in to your website's administration dashboard (for example, the WordPress admin panel at /wp-admin).
  2. Navigate to Plugins > Installed Plugins. Deactivate any recently installed plugins, particularly those related to backups, security scanning, or data imports, to identify if one is resource-heavy.
  3. Use a plugin such as Query Monitor to identify slow database queries or resource-intensive scripts.
  4. Check your scheduled tasks or cron jobs via your hosting control panel to ensure multiple heavy processes are not running simultaneously.
  5. Optimise your database tables using a tool like phpMyAdmin (found under Databases in cPanel) to remove overhead and improve query response times.

Review Server Resource Usage

Shared or underpowered hosting environments often have strict memory and processing caps. When these limits are reached, the server may stop responding to the gateway.

  1. Log in to your hosting control panel (cPanel or Plesk).
  2. In cPanel, navigate to Metrics > Resource Usage or CPU and Concurrent Connection Usage. In Plesk, go to Websites & Domains > PHP Settings.
  3. Check CPU, memory (RAM), and entry process limits to see if any are consistently maxed out.
  4. If resources are frequently at capacity, consider upgrading your hosting plan to accommodate your traffic and application needs.

Investigate Upstream Server Connectivity

A 504 error often points to a breakdown in communication between your web server and a backend service, such as a database server or API.

  1. Verify that your database service is running and accessible from your web server.
  2. Check your firewall settings to ensure the web server can communicate with upstream servers on the required ports (typically port 3306 for MySQL).
  3. Review server error logs for messages indicating connection refusals or timeouts to upstream services. Common log paths include /var/log/nginx/error.log for Nginx servers and /var/log/apache2/error.log for Apache servers.
  4. If you use a Content Delivery Network (CDN), check the CDN provider's status page for regional outages affecting Australian traffic.

PHP Execution Time and Proxy Timeouts

Server-side timeouts are often governed by specific configuration limits. If a script takes longer than the allowed limit to execute, the gateway will terminate the connection and return a 504 error.

Troubleshooting

Client-Side vs Server-Side Timeouts

Understanding where the timeout occurs helps determine the correct course of action.

Geographical Latency

If your website's servers are located overseas, Australian visitors may experience higher latency. While this usually causes slow loading rather than a 504 error, extremely long response times can contribute to gateway timeouts when combined with resource-heavy operations. Check your CDN status page to see if there are regional outages specifically affecting traffic from Australia.

Note: Monitoring your website during peak traffic periods can help you identify if timeouts occur only when resource demand is highest.

Warning: Avoid making changes to core server configuration files such as .htaccess or nginx.conf unless you are familiar with the syntax, as incorrect edits can take your website offline entirely.

When to Request Support

If the error persists after trying the steps above, gather the following information before contacting support:

Providing these details helps the support team diagnose the issue faster. You can submit your request via your hosting provider's support portal.

If you host with us, you don't need to do this yourself — Open a Ticket and our Brisbane team will get it sorted.

Still Having Issues?

Need more help? If the issue persists after trying these steps, please open a support ticket and our team will assist you.

💻 Open a Ticket