Cybersecurity glossary

What is HTTP Keep-Alive?

Learn what HTTP Keep-Alive is, how persistent connections reduce handshake overhead, how it relates to HTTP/1.1 and newer protocols, and which timeouts matter in production.

Web platform securityUpdated July 22, 2026
Also known asPersistent HTTP connection{ "Connection": "keep-alive" }HTTP persistent connections

Definition

HTTP Keep-Alive is the practice of keeping a TCP (or TLS) connection open so multiple HTTP requests and responses can reuse it, avoiding repeated handshakes and reducing latency for subsequent requests on the same connection.

Why Keep-Alive matters

Every new TCP connection costs time. With TLS, the cost is higher: certificate validation and key agreement add round trips. Pages and APIs that fetch many objects pay that cost repeatedly if connections close after each response.

HTTP Keep-Alive (persistent connections) amortizes handshake work across multiple requests. It is one of the simplest performance wins in HTTP/1.x and the conceptual ancestor of connection reuse in HTTP/2 and HTTP/3.

How persistent connections work

1

Client and server complete a handshake

TCP and usually TLS establish a secure channel for the first request.

2

First HTTP exchange completes

A request and response finish successfully without signaling Connection: close.

3

Connection stays idle but open

Both sides keep the socket alive waiting for another request within timeout limits.

4

Next request reuses the socket

No new handshake is needed; the client writes another HTTP message immediately.

5

Pools manage many connections

Browsers, proxies, and API clients keep per-origin pools with concurrency caps.

6

Idle timeout eventually closes

When unused too long—or max requests reached—the connection is shut down cleanly.

Keep-Alive across HTTP versions

VersionPersistence modelOperator notes
HTTP/1.0Optional via Connection: keep-aliveNot default; many old agents differed
HTTP/1.1Default unless Connection: closeClassic Keep-Alive timeouts still matter
HTTP/2Long-lived connection with multiplexed streamsConnection: keep-alive is not used as in HTTP/1.x
HTTP/3QUIC connection with independent streamsReuse remains critical; transport differs

Benefits and failure modes

Lower latency for follow-on requests

Asset waterfalls and API chatty sequences improve when handshakes are not repeated.

Reduced CPU on TLS terminators

Fewer handshakes mean less cryptographic setup under steady traffic.

Timeout mismatches

If a load balancer closes idle sockets before the app, clients see random connection resets.

Resource exhaustion

Huge idle pools can burn file descriptors and memory on proxies and origins.

Security and tenancy notes

Keep-Alive itself is not an authentication mechanism. Shared proxies must ensure one client’s credentials or connection state never leak onto another user’s reused connection. For mutual TLS or connection-level identity, understand whether identity is bound to the connection or re-validated per request.

Slowloris-style attacks also abuse long-lived connections by holding many barely-active sockets. Idle timeouts, connection limits, and reverse-proxy buffering policies are part of the defense.

Tuning checklist

  • Align idle timeouts: client → load balancer → reverse proxy → application, with clear margins.
  • Prefer Connection: close only for intentionally short-lived special cases—not as a global default.
  • Cap maximum requests per connection if you need to rotate sockets for balancing or memory reasons.
  • Monitor open connections, idle counts, and 502/504 spikes after timeout changes.
  • Size keep-alive pools on API clients to match upstream concurrency limits.
  • Ensure HTTP/2 and HTTP/3 settings also reflect desired max concurrent streams and connection age.
  • Review whether any connection-level auth assumptions break when sockets are reused.
  • Load-test with realistic idle gaps, not only continuous traffic.

The practical takeaway

HTTP Keep-Alive reuses an already-opened connection for multiple HTTP exchanges, cutting handshake overhead and latency. In HTTP/1.1 it is the default persistence model; in HTTP/2 and HTTP/3 the same idea continues through multiplexed long-lived sessions.

Treat Keep-Alive as an operations feature: tune timeouts end to end, watch idle resource use, and never confuse connection reuse with per-request security checks.

Related security terms

Frequently asked questions

What is HTTP Keep-Alive in simple terms?

It means leaving the network pipe open after one request so the next request does not pay for a brand-new connection setup.

Is Keep-Alive still relevant with HTTP/2 and HTTP/3?

Yes in spirit. Those protocols reuse connections aggressively; the old Connection: keep-alive header is an HTTP/1.x mechanism, while newer versions multiplex by design.

What headers are involved in HTTP/1.x?

Clients and servers may send Connection: keep-alive. HTTP/1.1 assumes persistence unless Connection: close is used. A Keep-Alive header can hint timeout and max request counts.

Can Keep-Alive cause problems?

Misaligned idle timeouts between load balancers and apps can cause intermittent 502/504 errors. Too many idle sockets can also exhaust file descriptors.

Does Keep-Alive improve security?

Not directly. It is a performance feature. Security still depends on TLS, authn, and correct connection isolation between users on shared proxies.

Should APIs disable Keep-Alive?

Rarely. Prefer tuning timeouts and pool sizes. Disabling persistence increases handshake load and latency under normal traffic.

How is this different from WebSockets?

Keep-Alive still uses request/response HTTP on a reused connection. WebSockets upgrade to a full-duplex message channel after the handshake.

References

Explore authoritative guidance and frameworks related to http keep-alive.

Explore every security definition

Return to the glossary to search by term, alias, starting letter, or security category.

Browse glossary