[{"data":1,"prerenderedAt":594},["ShallowReactive",2],{"content-query-h1AlVnyB28":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"layout":10,"crumb":11,"summary":12,"group":13,"order":14,"code":14,"updated":15,"cta":16,"related":24,"faq":43,"body":59,"_type":587,"_id":588,"_source":589,"_file":590,"_stem":591,"_extension":592,"sitemap":593},"/http-errors/504-gateway-timeout","http-errors",false,"","504 Gateway Timeout: what it means and how to fix it","504 Gateway Timeout means a proxy waited too long for the server behind it. Fixes for nginx proxy_read_timeout, Cloudflare 524, AWS ALB and webhooks.","reference","504 Gateway Timeout","A proxy gave up waiting for the app behind it.","5xx server errors",504,"2026-10-28",{"eyebrow":17,"title":18,"text":19,"to":20,"label":21,"secondaryTo":22,"secondaryLabel":23},"Webhook Relay Durable Retries","Slow endpoint? Don't lose the webhook","When a handler takes too long, the sender times out and counts a failure. Webhook Relay stores every webhook and retries with exponential backoff for up to 30 days, and throttling caps how many requests hit your endpoint at once.","/features/durable-retries/","See durable retries","/docs/webhooks/durable-webhooks/","Durable webhooks docs",[25,28,31,34,37,40],{"title":26,"to":27},"502 Bad Gateway","/http-errors/502-bad-gateway/",{"title":29,"to":30},"503 Service Unavailable","/http-errors/503-service-unavailable/",{"title":32,"to":33},"429 Too Many Requests","/http-errors/429-too-many-requests/",{"title":35,"to":36},"Reverse proxy","/glossary/reverse-proxy/",{"title":38,"to":39},"Webhook throttling","/features/throttling/",{"title":41,"to":42},"Webhook retries and idempotency","/blog/webhook-retries-and-idempotency/",[44,47,50,53,56],{"q":45,"a":46},"What does 504 Gateway Timeout mean?","A 504 Gateway Timeout means a proxy or gateway, such as nginx, Cloudflare or a load balancer, forwarded your request to the server behind it and didn't get a response in time. The upstream may still be working on the request; the proxy just stopped waiting.",{"q":48,"a":49},"How do I fix 504 Gateway Timeout in nginx?","The nginx error log shows upstream timed out while reading response header from upstream. Either make the upstream respond faster, or raise proxy_read_timeout, which defaults to 60 seconds, for the location that needs it. For PHP-FPM use fastcgi_read_timeout. Raising timeouts treats the symptom; slow requests usually need to become background jobs.",{"q":51,"a":52},"What is the difference between 502 and 504?","A 502 means the proxy got a bad response or none, for example because the app refused the connection or crashed. A 504 means the proxy connected and waited, but the app didn't answer before the timeout.",{"q":54,"a":55},"What is Cloudflare error 524?","Error 524 means Cloudflare connected to your origin but the origin didn't send an HTTP response within Cloudflare's timeout, 100 seconds by default. It's Cloudflare's version of a gateway timeout. Move long work out of the request or serve it from a path that responds quickly.",{"q":57,"a":58},"How do I stop webhook timeouts?","Respond quickly. Verify the signature, store the raw event, return 200, and do the slow work from a background queue. Providers usually wait only a few seconds to a few tens of seconds before counting a delivery as failed.",{"type":60,"children":61,"toc":580},"root",[62,82,149,156,211,217,222,228,403,408,460,466,471,500,541,547,574],{"type":63,"tag":64,"props":65,"children":66},"element","p",{},[67,80],{"type":63,"tag":68,"props":69,"children":70},"strong",{},[71,78],{"type":63,"tag":72,"props":73,"children":75},"code",{"className":74},[],[76],{"type":77,"value":11},"text",{"type":77,"value":79}," means a proxy or gateway (nginx, Cloudflare, a load balancer, an API gateway) forwarded the request to the server behind it and gave up waiting for a response.",{"type":77,"value":81}," The connection worked, but the upstream was too slow. It may even finish the work after the client has already seen the error.",{"type":63,"tag":83,"props":84,"children":88},"pre",{"className":85,"code":86,"language":87,"meta":7,"style":7},"language-http shiki shiki-themes github-dark","HTTP/1.1 504 Gateway Time-out\nServer: nginx\nContent-Type: text/html\n\n\u003Chtml>\u003Chead>\u003Ctitle>504 Gateway Time-out\u003C/title>\u003C/head>\n\u003Cbody>\u003Ccenter>\u003Ch1>504 Gateway Time-out\u003C/h1>\u003C/center>\u003Chr>\u003Ccenter>nginx\u003C/center>\u003C/body>\u003C/html>\n","http",[89],{"type":63,"tag":72,"props":90,"children":91},{"__ignoreMap":7},[92,103,112,121,131,140],{"type":63,"tag":93,"props":94,"children":97},"span",{"class":95,"line":96},"line",1,[98],{"type":63,"tag":93,"props":99,"children":100},{},[101],{"type":77,"value":102},"HTTP/1.1 504 Gateway Time-out\n",{"type":63,"tag":93,"props":104,"children":106},{"class":95,"line":105},2,[107],{"type":63,"tag":93,"props":108,"children":109},{},[110],{"type":77,"value":111},"Server: nginx\n",{"type":63,"tag":93,"props":113,"children":115},{"class":95,"line":114},3,[116],{"type":63,"tag":93,"props":117,"children":118},{},[119],{"type":77,"value":120},"Content-Type: text/html\n",{"type":63,"tag":93,"props":122,"children":124},{"class":95,"line":123},4,[125],{"type":63,"tag":93,"props":126,"children":128},{"emptyLinePlaceholder":127},true,[129],{"type":77,"value":130},"\n",{"type":63,"tag":93,"props":132,"children":134},{"class":95,"line":133},5,[135],{"type":63,"tag":93,"props":136,"children":137},{},[138],{"type":77,"value":139},"\u003Chtml>\u003Chead>\u003Ctitle>504 Gateway Time-out\u003C/title>\u003C/head>\n",{"type":63,"tag":93,"props":141,"children":143},{"class":95,"line":142},6,[144],{"type":63,"tag":93,"props":145,"children":146},{},[147],{"type":77,"value":148},"\u003Cbody>\u003Ccenter>\u003Ch1>504 Gateway Time-out\u003C/h1>\u003C/center>\u003Chr>\u003Ccenter>nginx\u003C/center>\u003C/body>\u003C/html>\n",{"type":63,"tag":150,"props":151,"children":153},"h2",{"id":152},"common-causes",[154],{"type":77,"value":155},"Common causes",{"type":63,"tag":157,"props":158,"children":159},"ul",{},[160,171,181,191,201],{"type":63,"tag":161,"props":162,"children":163},"li",{},[164,169],{"type":63,"tag":68,"props":165,"children":166},{},[167],{"type":77,"value":168},"A slow request.",{"type":77,"value":170}," A heavy database query, a report, an export, or a call to a slow third-party API, all inside the request.",{"type":63,"tag":161,"props":172,"children":173},{},[174,179],{"type":63,"tag":68,"props":175,"children":176},{},[177],{"type":77,"value":178},"An overloaded upstream.",{"type":77,"value":180}," Requests queue behind busy workers until they time out.",{"type":63,"tag":161,"props":182,"children":183},{},[184,189],{"type":63,"tag":68,"props":185,"children":186},{},[187],{"type":77,"value":188},"A stuck dependency.",{"type":77,"value":190}," The app waits on a database lock, a hung connection or a downstream service with no timeout of its own.",{"type":63,"tag":161,"props":192,"children":193},{},[194,199],{"type":63,"tag":68,"props":195,"children":196},{},[197],{"type":77,"value":198},"Network problems",{"type":77,"value":200}," between the proxy and the upstream: a firewall silently dropping packets, or a wrong IP that never answers.",{"type":63,"tag":161,"props":202,"children":203},{},[204,209],{"type":63,"tag":68,"props":205,"children":206},{},[207],{"type":77,"value":208},"Mismatched timeouts.",{"type":77,"value":210}," A proxy with a 30-second timeout in front of a job that routinely takes 45.",{"type":63,"tag":150,"props":212,"children":214},{"id":213},"how-to-fix-it-as-a-visitor",[215],{"type":77,"value":216},"How to fix it as a visitor",{"type":63,"tag":64,"props":218,"children":219},{},[220],{"type":77,"value":221},"Wait and try again. If you were submitting something like a payment or a form, check whether it went through before resubmitting, because the server may have finished the work after the timeout.",{"type":63,"tag":150,"props":223,"children":225},{"id":224},"how-to-fix-it-as-a-developer-or-ops",[226],{"type":77,"value":227},"How to fix it as a developer or ops",{"type":63,"tag":229,"props":230,"children":231},"table",{},[232,261],{"type":63,"tag":233,"props":234,"children":235},"thead",{},[236],{"type":63,"tag":237,"props":238,"children":239},"tr",{},[240,246,251,256],{"type":63,"tag":241,"props":242,"children":243},"th",{},[244],{"type":77,"value":245},"Where",{"type":63,"tag":241,"props":247,"children":248},{},[249],{"type":77,"value":250},"What you see",{"type":63,"tag":241,"props":252,"children":253},{},[254],{"type":77,"value":255},"Default timeout",{"type":63,"tag":241,"props":257,"children":258},{},[259],{"type":77,"value":260},"Setting",{"type":63,"tag":262,"props":263,"children":264},"tbody",{},[265,307,334,369],{"type":63,"tag":237,"props":266,"children":267},{},[268,274,283,288],{"type":63,"tag":269,"props":270,"children":271},"td",{},[272],{"type":77,"value":273},"nginx",{"type":63,"tag":269,"props":275,"children":276},{},[277],{"type":63,"tag":72,"props":278,"children":280},{"className":279},[],[281],{"type":77,"value":282},"upstream timed out (110: Connection timed out) while reading response header from upstream",{"type":63,"tag":269,"props":284,"children":285},{},[286],{"type":77,"value":287},"60s",{"type":63,"tag":269,"props":289,"children":290},{},[291,297,299,305],{"type":63,"tag":72,"props":292,"children":294},{"className":293},[],[295],{"type":77,"value":296},"proxy_read_timeout",{"type":77,"value":298},", ",{"type":63,"tag":72,"props":300,"children":302},{"className":301},[],[303],{"type":77,"value":304},"fastcgi_read_timeout",{"type":77,"value":306}," for PHP-FPM",{"type":63,"tag":237,"props":308,"children":309},{},[310,315,324,329],{"type":63,"tag":269,"props":311,"children":312},{},[313],{"type":77,"value":314},"Cloudflare",{"type":63,"tag":269,"props":316,"children":317},{},[318],{"type":63,"tag":72,"props":319,"children":321},{"className":320},[],[322],{"type":77,"value":323},"Error 524: A timeout occurred",{"type":63,"tag":269,"props":325,"children":326},{},[327],{"type":77,"value":328},"100s",{"type":63,"tag":269,"props":330,"children":331},{},[332],{"type":77,"value":333},"Raised only on Enterprise; otherwise make the origin respond faster",{"type":63,"tag":237,"props":335,"children":336},{},[337,342,353,358],{"type":63,"tag":269,"props":338,"children":339},{},[340],{"type":77,"value":341},"AWS ALB",{"type":63,"tag":269,"props":343,"children":344},{},[345,351],{"type":63,"tag":72,"props":346,"children":348},{"className":347},[],[349],{"type":77,"value":350},"504",{"type":77,"value":352}," in access logs",{"type":63,"tag":269,"props":354,"children":355},{},[356],{"type":77,"value":357},"60s idle timeout",{"type":63,"tag":269,"props":359,"children":360},{},[361,363],{"type":77,"value":362},"Load balancer attribute ",{"type":63,"tag":72,"props":364,"children":366},{"className":365},[],[367],{"type":77,"value":368},"idle_timeout.timeout_seconds",{"type":63,"tag":237,"props":370,"children":371},{},[372,377,393,398],{"type":63,"tag":269,"props":373,"children":374},{},[375],{"type":77,"value":376},"AWS API Gateway",{"type":63,"tag":269,"props":378,"children":379},{},[380,385,387],{"type":63,"tag":72,"props":381,"children":383},{"className":382},[],[384],{"type":77,"value":350},{"type":77,"value":386}," / ",{"type":63,"tag":72,"props":388,"children":390},{"className":389},[],[391],{"type":77,"value":392},"Endpoint request timed out",{"type":63,"tag":269,"props":394,"children":395},{},[396],{"type":77,"value":397},"29s for REST integrations",{"type":63,"tag":269,"props":399,"children":400},{},[401],{"type":77,"value":402},"Integration timeout",{"type":63,"tag":64,"props":404,"children":405},{},[406],{"type":77,"value":407},"Raising a timeout is fine when a request is legitimately long. More often, the real fix is in the app:",{"type":63,"tag":409,"props":410,"children":411},"ol",{},[412,422,440,450],{"type":63,"tag":161,"props":413,"children":414},{},[415,420],{"type":63,"tag":68,"props":416,"children":417},{},[418],{"type":77,"value":419},"Find the slow part.",{"type":77,"value":421}," APM traces, slow query logs or timing logs around external calls.",{"type":63,"tag":161,"props":423,"children":424},{},[425,430,432,438],{"type":63,"tag":68,"props":426,"children":427},{},[428],{"type":77,"value":429},"Move long work out of the request.",{"type":77,"value":431}," Accept the job, return ",{"type":63,"tag":72,"props":433,"children":435},{"className":434},[],[436],{"type":77,"value":437},"202 Accepted",{"type":77,"value":439}," with a job ID, and let the client poll or receive a webhook when it's done.",{"type":63,"tag":161,"props":441,"children":442},{},[443,448],{"type":63,"tag":68,"props":444,"children":445},{},[446],{"type":77,"value":447},"Put timeouts on outbound calls",{"type":77,"value":449},", shorter than the proxy's, so the app can return a clean error instead of hanging.",{"type":63,"tag":161,"props":451,"children":452},{},[453,458],{"type":63,"tag":68,"props":454,"children":455},{},[456],{"type":77,"value":457},"Add capacity",{"type":77,"value":459}," if requests are timing out in a queue rather than in your code.",{"type":63,"tag":150,"props":461,"children":463},{"id":462},"_504s-and-timeouts-on-a-webhook-endpoint",[464],{"type":77,"value":465},"504s and timeouts on a webhook endpoint",{"type":63,"tag":64,"props":467,"children":468},{},[469],{"type":77,"value":470},"Webhook senders wait only a short time for your response, usually a few seconds to a few tens of seconds. If your handler does the work inline (calls an API, writes several rows, sends an email), a slow moment turns into a timeout, the provider records a failure and retries. Your handler may have actually finished, so the retry becomes a duplicate.",{"type":63,"tag":64,"props":472,"children":473},{},[474,476,489,491,498],{"type":77,"value":475},"The pattern that avoids it: ",{"type":63,"tag":68,"props":477,"children":478},{},[479,481,487],{"type":77,"value":480},"verify the signature, store the raw event, return ",{"type":63,"tag":72,"props":482,"children":484},{"className":483},[],[485],{"type":77,"value":486},"200",{"type":77,"value":488},", process asynchronously.",{"type":77,"value":490}," Then make processing ",{"type":63,"tag":492,"props":493,"children":495},"a",{"href":494},"/glossary/idempotency/",[496],{"type":77,"value":497},"idempotent",{"type":77,"value":499}," so a retried delivery doesn't run twice.",{"type":63,"tag":64,"props":501,"children":502},{},[503,505,510,512,517,519,525,527,533,535,539],{"type":77,"value":504},"If timeouts come from bursts, Webhook Relay ",{"type":63,"tag":492,"props":506,"children":507},{"href":39},[508],{"type":77,"value":509},"throttling",{"type":77,"value":511}," limits the rate or number of concurrent deliveries to your endpoint so it isn't flooded. And ",{"type":63,"tag":492,"props":513,"children":514},{"href":20},[515],{"type":77,"value":516},"durable retries",{"type":77,"value":518}," keep each event and retry with exponential backoff for up to 30 days, so a slow afternoon never loses data. For webhooks forwarded to ",{"type":63,"tag":72,"props":520,"children":522},{"className":521},[],[523],{"type":77,"value":524},"localhost",{"type":77,"value":526}," through ",{"type":63,"tag":72,"props":528,"children":530},{"className":529},[],[531],{"type":77,"value":532},"relay forward",{"type":77,"value":534},", a provider reporting a timeout can also mean the agent couldn't reach your local server. See ",{"type":63,"tag":492,"props":536,"children":537},{"href":27},[538],{"type":77,"value":26},{"type":77,"value":540}," for that case.",{"type":63,"tag":150,"props":542,"children":544},{"id":543},"when-to-return-504-from-your-own-service",[545],{"type":77,"value":546},"When to return 504 from your own service",{"type":63,"tag":64,"props":548,"children":549},{},[550,552,557,559,564,566,572],{"type":77,"value":551},"Return ",{"type":63,"tag":72,"props":553,"children":555},{"className":554},[],[556],{"type":77,"value":350},{"type":77,"value":558}," only when your service is a gateway or proxy and the upstream it called didn't answer in time. If your own handler is slow, fix the handler or return ",{"type":63,"tag":72,"props":560,"children":562},{"className":561},[],[563],{"type":77,"value":437},{"type":77,"value":565}," and finish the work in the background. For a timeout that happens because the client was too slow to send the request, the code is ",{"type":63,"tag":72,"props":567,"children":569},{"className":568},[],[570],{"type":77,"value":571},"408 Request Timeout",{"type":77,"value":573},".",{"type":63,"tag":575,"props":576,"children":577},"style",{},[578],{"type":77,"value":579},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":114,"depth":114,"links":581},[582,583,584,585,586],{"id":152,"depth":105,"text":155},{"id":213,"depth":105,"text":216},{"id":224,"depth":105,"text":227},{"id":462,"depth":105,"text":465},{"id":543,"depth":105,"text":546},"markdown","content:http-errors:504-gateway-timeout.md","content","http-errors/504-gateway-timeout.md","http-errors/504-gateway-timeout","md",{"loc":4},1793199803436]