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.
Table of Contents
Default timeouts: the reference
Web servers
| Layer | Setting | Default | When exceeded |
|---|---|---|---|
| Nginx | proxy_read_timeout | 60 s | 504 Gateway Timeout |
| Nginx | proxy_connect_timeout | 60 s | 504 |
| Nginx | fastcgi_read_timeout (PHP-FPM) | 60 s | 504 |
| Nginx | client_body_timeout / client_header_timeout | 60 s | 408 Request Timeout |
| Nginx | keepalive_timeout | 75 s | Idle connection closed |
| Apache HTTP Server | Timeout | 60 s | 504 when proxying, 408 on slow clients |
| Apache HTTP Server | ProxyTimeout | Same as Timeout | 504 |
| Apache HTTP Server | KeepAliveTimeout | 5 s | Idle connection closed |
| Apache mod_fcgid | FcgidIOTimeout | 40 s | 500 |
| Microsoft IIS | connectionTimeout | 120 s | Connection closed |
PHP and application servers
| Layer | Setting | Default | When exceeded |
|---|---|---|---|
| PHP | max_execution_time | 30 s (unlimited on the command line) | Fatal error — usually a 500 |
| PHP | max_input_time | 60 s in php.ini-production | Request data rejected |
| PHP | default_socket_timeout | 60 s | Outbound connection fails |
| PHP-FPM | request_terminate_timeout | Disabled (0) | Worker killed — 502 or 504 |
| WordPress | HTTP API (wp_remote_get) | 5 s | WP_Error returned |
| Gunicorn (Python) | --timeout | 30 s | Worker killed — 502 from the proxy |
Node.js http server | requestTimeout | 300 s (Node 18+) | 408 |
Node.js http server | headersTimeout | 60 s | 408 |
Node.js http server | keepAliveTimeout | 5 s | Idle connection closed |
| ASP.NET (.NET Framework) | executionTimeout | 110 s | Request 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
| Database | Setting | Default | What it does |
|---|---|---|---|
| MySQL / MariaDB | wait_timeout | 28,800 s (8 hours) | Closes idle connections — “MySQL server has gone away” |
| MySQL / MariaDB | connect_timeout | 10 s | Fails the connection handshake |
| MySQL / MariaDB | innodb_lock_wait_timeout | 50 s | “Lock wait timeout exceeded” |
| MySQL | max_execution_time (SELECT) | Disabled (0) | Aborts long read queries |
| PostgreSQL | statement_timeout | Disabled (0) | Cancels long statements |
| PostgreSQL | idle_in_transaction_session_timeout | Disabled (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
| Layer | Limit | Default | When exceeded |
|---|---|---|---|
| Cloudflare | Connection to the origin (TCP handshake) | 19 s | 522 |
| Cloudflare | Origin acknowledging the request | 90 s | 522 |
| Cloudflare | Proxy Read Timeout | 120 s — raisable only on Enterprise, up to 6,000 s | 524 |
| Cloudflare | Proxy Write Timeout | 30 s — fixed | 524 |
| AWS Application Load Balancer | Idle timeout | 60 s | 504 |
| Amazon API Gateway (REST) | Integration timeout | 29 s — raisable on Regional and private APIs | 504 |
| AWS Lambda | Function timeout | 3 s (maximum 15 minutes) | Invocation fails |
| Amazon CloudFront | Origin response timeout | 30 s | 504 |
| Google Cloud Run | Request timeout | 300 s (maximum 60 minutes) | 504 |
| Google Cloud load balancer | Backend service timeout | 30 s | 408 or 504 |
| Azure App Service | Request timeout | 230 s — fixed | 500 or 504 |
HTTP clients
| Client | Default | Note |
|---|---|---|
| curl | No total timeout; 300 s to connect | Set --max-time for scripts |
Python requests | No timeout at all | A request can hang forever — always pass timeout= |
Node.js fetch | 300 s for headers and for the body | Set 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) → MySQLHere, 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 see | The timer that fired |
|---|---|
| 504 with nginx on the page | proxy_read_timeout or fastcgi_read_timeout |
| 524 on a Cloudflare page | Cloudflare’s Proxy Read Timeout |
| 522 on a Cloudflare page | The origin didn’t accept the connection in time |
| 502 after about 30 seconds on a Python app | Gunicorn 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.
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.
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
- Nginx: ngx_http_proxy_module and ngx_http_core_module
- Apache: core — Timeout
- PHP: Runtime configuration — max_execution_time
- Cloudflare: Error 522 and Error 524
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.
