504 Gateway Timeout Error Through a Proxy
An intermediary server waited for a response from the next server in the chain and did not get it. It is important to understand which intermediary answered.
Updated · Prokso editorial team
- Code 504 comes from an intermediary that got no timely response from the next server
- Most often the site takes too long to process the request or is overloaded
- Retry the request in a minute, then open the site without the proxy
What the error means
According to the HTTP standard (RFC 9110), the 504 code is sent by a server acting as a gateway or proxy when it did not receive a timely response from the server it needed to contact to complete the request.
There may be several intermediaries in the chain: the proxy you work through, and further on a CDN, a load balancer or nginx in front of the site itself. Any of them can send 504. The design of the error page often shows who answered: Cloudflare, for example, has its own codes 522 and 524.
504 differs from a regular timeout in the program in that a response did arrive: it is just a message from the intermediary that it did not get a reply in time.
Causes
- The site takes too long to process the request. A heavy report, an export, a search without limits: the site's server does not finish within the time the intermediary gives it.
- The site is overloaded or unavailable. The intermediary in front of the site cannot reach the server with the data.
- A slow exit address. Residential and mobile IPs are devices on home and mobile internet connections, and their speed varies.
- A large response size. Large files and pages take longer to deliver than the intermediary's settings allow for.
How to fix it
- Retry the request in a minute: 504 is often temporary.
- Open the site without the proxy. If you get 504 there too, the problem is on the site's side, and a proxy cannot fix it.
- Look at the error page: a Cloudflare design points to a site behind Cloudflare; in that case see the 524 error and 522.
- Reduce the size of a single request: result pages, date filters, exports in parts.
- On a sticky IP, change the session: take a different port from the 10000-20000 range if the current address responds slowly.
- Compare with a proxy timeout: if the program drops the connection itself, without a 504 code, the cause is different.
How to check that it works
The proxy checker shows the response time of the address. If the proxy responds quickly and 504 comes from only one site and only on heavy requests, the delay is on the site's side.
Two-minute diagnosis
First paste the line into the proxy checker. If the proxy works there, the cause is in your app or its settings. If not, test the line from a terminal:
curl -v -x "http://USERNAME:PASSWORD@gw.prokso.com:823" https://api.ipify.org
- A
< HTTP/1.1 407line right afterCONNECTmeans the proxy answered. The name after the code, for exampleNO_USER, points to the cause. - The proxy answered
CONNECTwith 200 and then another code arrived - the proxy works, and that answer came from the website. - No answer at all, only a timeout - the connection never reached the proxy: check the host, port and network.
FAQ
Is 504 a proxy error?
Not necessarily. The code is sent by the intermediary that did not get a reply in time. Often that is the server in front of the site itself, not the proxy.
How is 504 different from 502?
502 means the intermediary received an invalid response from the next server or could not connect to it. 504 means there was no response in time. About 502, see the <a href="/en/errors/502-bad-gateway">separate page</a>.
Will increasing the timeout in the program help?
The timeout in the program does not affect the intermediary that has already answered 504. It only helps when the program itself stops waiting before the response arrives.
Other proxy errors
Residential $1.59, mobile $2.50, datacenter $0.65 per GB
Sign up in a minute, get access right after payment.