The HTTP keep-alive timeout is the time a server keeps an already-used HTTP/1.1 connection open while waiting for another request on it. If nothing arrives before the timer expires, the server closes the connection.
Why it matters
Reusing a connection avoids repeating the TCP and TLS handshakes, which saves latency for pages that load many assets. But every open connection consumes memory and a worker slot. Too short and clients reconnect constantly; too long and a busy server runs out of connections to idle clients. It also interacts with proxies: a backend timeout shorter than the proxy's causes occasional reset or 502 errors.
Example
Typical directives, with values you should tune for your own traffic:
nginx:
keepalive_timeout 15s;
Apache:
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 100
The server may also advertise its value to clients with a header such as Keep-Alive: timeout=5. Use the header checker to see what your server sends.
Common mistakes
- Using a large value on Apache with prefork workers, where each idle connection holds a whole process.
- Setting the origin timeout lower than the CDN or load balancer's idle timeout.
- Confusing this with the request timeout, which limits how long one request may take.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.