HTTP error 504
504 Gateway Timeout: what it means and how to fix it
The short answer
Nothing has necessarily crashed. Something is just too slow, and the server in front stopped waiting before your site could answer.
- Backup before every change
- Fixed price before we start
- Remote, anywhere in the world
- Free diagnosis
A 504 is a timing problem, and every layer has its own stopwatch. By default nginx waits 60 seconds for PHP, PHP stops a script after 30 seconds (max_execution_time), and Cloudflare reports its own 524 when your server takes longer than 100 seconds. Whichever stopwatch runs out first decides which error you see.
Sound familiar?
What a 504 Gateway Timeout looks like
- A page that says “504 Gateway Timeout” or, on nginx, “Gateway Time-out”
- A Cloudflare page with “Error 524: A timeout occurred”
- Only certain pages fail: search, reports, checkout, an import or the admin area
- A page spins for 30 to 60 seconds and then fails
- It got worse as your database or traffic grew, or after a new plugin or import
Causes
Common reasons for a 504 Gateway Timeout
Slow database queries
A query that scans a large table without an index can take many seconds. As your data grows, a page that used to load quickly slides over the timeout.
Slow scripts or heavy pages
Page builders, big product listings, image processing or reports that do too much work in a single request.
External API calls that hang
If your site waits for a payment provider, shipping service or another API that does not answer, the page waits too, until the gateway gives up.
Heavy imports, backups or cron jobs
A job that runs during business hours takes workers and database capacity away from visitors.
Timeout limits that do not match
If the gateway’s timeout is shorter than the time PHP is allowed to run, the gateway always loses. The limits must fit the work a page really does.
The upstream server is overloaded
When PHP workers or the database are busy with other requests, new ones wait in line until the timeout hits.
Try it yourself
Quick checks for a 504 Gateway Timeout
Safe things to check first. Raising limits is the last step, not the first.
- 1 Note which URLs fail. If only a few do (search, checkout, one admin page), the cause is a heavy page and not the whole server.
- 2 Check what runs at the same time: a backup, an import, a search re-index or a cron job. Pause it and retry.
- 3 Look at the logs. In nginx, “upstream timed out (110: Connection timed out) while reading response header from upstream” confirms the wait; PHP’s slow log shows which script was running.
- 4 On WordPress, rename wp-content/plugins to plugins-off for a moment. Backup, security-scan, related-posts and page-builder plugins are common culprits.
- 5 Ask your host whether the MySQL slow query log can be enabled. It lists exactly which queries take seconds. Make a backup before cleaning or optimising any tables.
- 6 Only then raise the timeout, for example max_execution_time or fastcgi_read_timeout, as a temporary measure. A page that needs 90 seconds still frustrates visitors.
Our approach
How we resolve a 504 Gateway Timeout
-
1
We find the slow request
We trace which page, query or call takes the time, using the web server, PHP and database logs, so we fix the slow part rather than the symptom.
-
2
Backup before any change
A full copy of files and database comes first, so every change can be undone.
-
3
Cause, fixed price, your OK
The diagnosis is free. You get the cause in plain language, a fixed price and a time estimate. Nothing starts without your yes.
-
4
Speed up, test and report
We make the slow part faster, set timeouts that fit the work, check the pages that failed and send a short report.
What we need
What we need from you
- Access to your hosting panel or SSH, including the web server and PHP logs
- Database access, or the ability to enable the slow query log
- An admin login for your CMS or application, if there is one
- Which pages or actions fail, when it began and what changed before
We ask for the least access that does the job, use a separate key per client, and you can revoke it the moment we are done.
What we cannot fix
We cannot fix a 504 caused by a slow third-party service that we do not control, or by a hosting plan that is simply too small for the work. In those cases we tell you after the free diagnosis, show you where the time goes, and advise on the realistic options.
Price
Price and what happens next
-
1
Free diagnosis
We find the cause and tell you what is wrong.
-
2
Fixed price
You get a price and a time estimate. Nothing starts without your yes.
-
3
Fixed and reported
We repair it, test it and send a short report.
From €295 excl. VAT
Fixed price, agreed before we start
Is it urgent? Say so in the form or in the chat. We start as soon as we can and give you a realistic time estimate with the quote. If priority work costs extra, you see that in the quote before you agree.
Get it fixedQuestions?
FAQ about the 504 Gateway Timeout
Also see
Related problems
HTTP error 502
A 502 Bad Gateway means a server acting as a gateway or proxy, such as nginx or Cloudflare, received an invalid or no response from the serv...
Read more →HTTP error 503
A 503 Service Unavailable means the server is running but cannot handle your request right now, because it is overloaded, in maintenance mod...
Read more →Database connection error
“Error establishing a database connection” means your site’s code runs but cannot reach or log in to the database that holds your content. M...
Read more →Last updated:
Request
Tell us what is wrong
Answer a few short questions. You get a fixed price before we do anything.
Thank you for your request!
We will contact you shortly
An error occurred!
Please try again.