Help for owners
My website says 504 Gateway Timeout
Short answer
A 504 Gateway Timeout means the server in front of your site waited for the application behind it and got no answer in time. The cause is a slow or overloaded application, a heavy request, or a database that is struggling. It needs someone to read the logs, not a guess.
Does this sound like your situation?
- The page loads for a long time and then shows 504.
- Only some pages, such as reports or checkout, fail.
- The site gets slow before it fails.
- It is worse at busy hours.
Why does this happen?
The application took too long
MDN describes a 504 as a gateway or proxy not getting a response in time from the upstream server. Usually that means the code is busy or stuck on a slow request.
Confirmed by developer.mozilla.org
A heavy page or job runs inside a normal request
Exports, reports, imports and large image processing can run longer than the front server will wait.
Technical detail: nginx gives up waiting for the app and returns 504
The database is slow
If the database behind the site is slow or locked, the application waits for it and the front server gives up.
Technical detail: A statement waited for a lock held by another transaction and gave up (error 1205)
A time limit is set too low
Web servers and hosting platforms set their own time limits. A page that needs longer than the limit will always time out.
Technical detail: A Next.js route handler is cut off after a fixed time
What can I do about it today?
- Note which pages failDoes the whole site time out or only certain pages? Write down the addresses.
- Check from another networkThe same page that defines 504 says client network, VPN or DNS issues can cause it, so test on mobile data or ask a colleague.
- Do not repeat a payment or an orderIf the failing page submits an order or payment, do not click again and again. Check first whether it went through.
- Wait a short while and try onceThe page says the site may work again later, but a repeating 504 needs investigation.
- Report it with timesSend your developer or host the time of the error, the page and what you were doing.
When should I bring someone in?
- The 504 repeats every day at the same hours.
- Checkout or booking pages fail.
- The site is slow even when it is not showing errors.
How do I handle it?
- Look at the logs firstI read the web server and application logs for the exact minute the problem started, before I change anything.
- Take a backupBefore a production change I take a backup and note how to go back.
- Fix the proven causeI change one thing, then test it from outside, the way a visitor would.
- Add the early warningI set up a check that tells you when it starts again, so you hear about it before your customers do, and write down what happened.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
Can I just raise the time limit?
Sometimes it is part of the answer, but a longer wait hides a slow request. I find out why it is slow first.
Is a 504 caused by too much traffic?
It can be. A slow application under load is one of several causes, and the logs show which.
Will it go away by itself?
Sometimes it does, according to MDN, but if it returns it will keep costing you visitors until the cause is fixed.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.
For your developer: the technical fixes
504 Gateway Time-outnginx gives up waiting for the app and returns 504Route handler stops after a fixed number of seconds on production but not locallyA Next.js route handler is cut off after a fixed timeFatal error: Maximum execution time of 30 seconds exceeded in /var/www/app/import.php on line 42PHP stops the script after 30 secondsERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transactionA statement waited for a lock held by another transaction and gave up (error 1205)