Default Timeouts: Nginx, Apache, PHP, Cloudflare, AWS and More

A request that takes too long doesn’t fail at one place — it fails at whichever layer gives up first. The CDN, the load balancer, the web server, PHP and the database each have their own timeout, and each one produces a different error: a 504 from Nginx, a 524 from Cloudflare, a fatal error from PHP.

This page collects the default timeouts in one place, with the error each one produces when it’s exceeded. The timeout that applies is always the shortest one on the path — so knowing all of them is the fastest way to find which one cut the request off.

This page is part of our series of server references, alongside default request size limits, control panel ports and how to verify search engine and AI crawlers.

Last verified: September 2026. Defaults change between versions — Cloudflare’s own read timeout moved from 100 to 120 seconds in its current documentation. Hosting providers often change defaults too, so check your own configuration before relying on one.

Default timeouts: the reference

Web servers

LayerSettingDefaultWhen exceeded
Nginxproxy_read_timeout60 s504 Gateway Timeout
Nginxproxy_connect_timeout60 s504
Nginxfastcgi_read_timeout (PHP-FPM)60 s504
Nginxclient_body_timeout / client_header_timeout60 s408 Request Timeout
Nginxkeepalive_timeout75 sIdle connection closed
Apache HTTP ServerTimeout60 s504 when proxying, 408 on slow clients
Apache HTTP ServerProxyTimeoutSame as Timeout504
Apache HTTP ServerKeepAliveTimeout5 sIdle connection closed
Apache mod_fcgidFcgidIOTimeout40 s500
Microsoft IISconnectionTimeout120 sConnection closed

PHP and application servers

LayerSettingDefaultWhen exceeded
PHPmax_execution_time30 s (unlimited on the command line)Fatal error — usually a 500
PHPmax_input_time60 s in php.ini-productionRequest data rejected
PHPdefault_socket_timeout60 sOutbound connection fails
PHP-FPMrequest_terminate_timeoutDisabled (0)Worker killed — 502 or 504
WordPressHTTP API (wp_remote_get)5 sWP_Error returned
Gunicorn (Python)--timeout30 sWorker killed — 502 from the proxy
Node.js http serverrequestTimeout300 s (Node 18+)408
Node.js http serverheadersTimeout60 s408
Node.js http serverkeepAliveTimeout5 sIdle connection closed
ASP.NET (.NET Framework)executionTimeout110 sRequest aborted

⚠️ max_execution_time counts only the time PHP spends executing — not time spent waiting on a database query or an external API on most systems. A script can run well past 30 seconds of wall-clock time without triggering it, and then be cut off by Nginx’s 60 seconds instead.

Databases

DatabaseSettingDefaultWhat it does
MySQL / MariaDBwait_timeout28,800 s (8 hours)Closes idle connections — “MySQL server has gone away”
MySQL / MariaDBconnect_timeout10 sFails the connection handshake
MySQL / MariaDBinnodb_lock_wait_timeout50 s“Lock wait timeout exceeded”
MySQLmax_execution_time (SELECT)Disabled (0)Aborts long read queries
PostgreSQLstatement_timeoutDisabled (0)Cancels long statements
PostgreSQLidle_in_transaction_session_timeoutDisabled (0)Ends idle transactions

For every other MySQL and MariaDB default — connection limits, packet size, buffer pool — and the error each one causes, see our MySQL and MariaDB defaults reference.

CDNs, load balancers and cloud platforms

LayerLimitDefaultWhen exceeded
CloudflareConnection to the origin (TCP handshake)19 s522
CloudflareOrigin acknowledging the request90 s522
CloudflareProxy Read Timeout120 s — raisable only on Enterprise, up to 6,000 s524
CloudflareProxy Write Timeout30 s — fixed524
AWS Application Load BalancerIdle timeout60 s504
Amazon API Gateway (REST)Integration timeout29 s — raisable on Regional and private APIs504
AWS LambdaFunction timeout3 s (maximum 15 minutes)Invocation fails
Amazon CloudFrontOrigin response timeout30 s504
Google Cloud RunRequest timeout300 s (maximum 60 minutes)504
Google Cloud load balancerBackend service timeout30 s408 or 504
Azure App ServiceRequest timeout230 s — fixed500 or 504

HTTP clients

ClientDefaultNote
curlNo total timeout; 300 s to connectSet --max-time for scripts
Python requestsNo timeout at allA request can hang forever — always pass timeout=
Node.js fetch300 s for headers and for the bodySet via the dispatcher or an AbortSignal

The shortest timeout wins — and names the error

A slow request passes several timers, and the first one to expire decides what the visitor sees. A typical WordPress site behind Cloudflare:

Visitor → Cloudflare (120 s) → Nginx (60 s) → PHP-FPM → PHP (30 s of execution) → MySQL

Here, a page that needs 90 seconds never reaches Cloudflare’s limit: Nginx gives up at 60 seconds and returns a 504. Raising PHP’s max_execution_time to 300 changes nothing until fastcgi_read_timeout goes up too.

The error code is the fastest clue to which timer fired:

You seeThe timer that fired
504 with nginx on the pageproxy_read_timeout or fastcgi_read_timeout
524 on a Cloudflare pageCloudflare’s Proxy Read Timeout
522 on a Cloudflare pageThe origin didn’t accept the connection in time
502 after about 30 seconds on a Python appGunicorn killed the worker
“Maximum execution time of 30 seconds exceeded”PHP’s max_execution_time
“MySQL server has gone away”wait_timeout closed an idle connection

Our guides to 504 Gateway Timeout and to increasing PHP limits cover the fix for each.

Timeout calculator: which one fires first?

Try it with your own stack. Enter how long the request takes and the layers in front of it — the calculator shows which timer expires first, the error your visitors will see, and every timeout you would need to raise to let the request finish.

Which timeout fires first?

Enter how long the request takes and the layers on its path. Defaults are pre-filled — change any value to match your configuration. Use 0 for a timeout that is disabled.

s — Proxy Read Timeout
s
s
s

Defaults from the tables above, verified September 2026. On most systems, PHP’s max_execution_time counts only time spent executing code, not time waiting on a database or an API. Source: copahost.com

Raise the timeout — or make the request faster?

Raising a timeout doesn’t make anything faster — it only lets slow work run longer before failing. It’s the right fix for a legitimately long operation, like a large export. It’s the wrong one for a page that should load in a second and takes forty.

For long jobs, the better pattern is to take them out of the request entirely: start the work in the background, return immediately, and let the browser check on progress. Imports, exports, video processing and reports all fit this pattern — and they stop depending on every timeout on the path. If you do raise timeouts, raise them along the whole path, and only on the route that needs it.

Sources

Set every timeout on the path yourself

A Copahost VPS gives you root access to Nginx, Apache, PHP-FPM and MySQL — so a long export can have the time it needs while the rest of the site keeps safe defaults. On shared hosting, PHP’s execution time is adjustable per domain in cPanel’s MultiPHP INI Editor.

See VPS plans →

Frequently asked questions

What is the default timeout in Nginx?
60 seconds for most timeouts, including proxy_read_timeout, proxy_connect_timeout and fastcgi_read_timeout. When a backend doesn’t answer in time, Nginx returns a 504 Gateway Timeout. The keep-alive timeout is 75 seconds.

What is the default max_execution_time in PHP?
30 seconds, and unlimited when PHP runs from the command line. It counts only the time the script spends executing, so waiting on a database or an external API usually doesn’t count toward it.

What is Cloudflare’s timeout?
Cloudflare waits 120 seconds for the origin to respond before returning a 524 — its current documentation replaced the long-cited 100 seconds. It waits 19 seconds for the connection itself, returning a 522. Only Enterprise plans can raise the read timeout, up to 6,000 seconds. A 522 usually means a firewall is silently dropping Cloudflare’s connections; our Cloudflare IP allowlist generator writes the rules to let them through.

Why does my request still time out after raising PHP’s limit?
Because another layer on the path has a shorter timeout. With Nginx in front of PHP-FPM, fastcgi_read_timeout defaults to 60 seconds and cuts the request off regardless of PHP’s setting — raise both together.

Does Python requests have a default timeout?
No. Without a timeout argument, a request can wait indefinitely for a server that never answers. Always set one — for example timeout=(5, 30), for connecting and for reading.

Conclusion

Timeouts stack. The CDN, the load balancer, the web server, PHP and the database each keep their own clock, and the shortest one decides where a slow request dies — and which error the visitor sees.

A handful of defaults cause most of the trouble: Nginx’s 60 seconds, PHP’s 30 seconds of execution, Gunicorn’s 30 seconds, API Gateway’s 29, and Cloudflare’s 120 — not the 100 still quoted almost everywhere. When a request fails at a suspiciously round number, the table above usually names the layer.

And before raising any of them, ask whether the request should take that long at all. The best fix for a slow page is a faster page; for genuinely long work, it’s a background job that doesn’t depend on any of these clocks.

Share the Post:
Picture of Gustavo Gallas

Gustavo Gallas

Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development​. Also have brewing skills.