Connection
Request & response Connection

Overview

Connection controls how the current transport connection is handled: whether to keep it open for reuse (keep-alive), close it after the response (close), or switch protocols (upgrade). It is central to persistent-connection management in HTTP/1.1.

Details

HTTP/1.1 keeps connections alive by default, reusing one TCP connection across many request/response pairs. This saves TCP handshake and TLS negotiation costs and greatly improves performance. `Connection: close` says the connection will be torn down after this message, while `Connection: upgrade` pairs with the `Upgrade` header to request switching to another protocol like WebSocket (101 Switching Protocols).

Connection is a hop-by-hop header: it is valid only between two adjacent nodes, not end-to-end, and a proxy consumes rather than forwards it. It also marks the header names it lists (e.g. `Connection: Keep-Alive`) as hop-by-hop, so they too are stripped before forwarding.

HTTP/2 and HTTP/3 fundamentally change connection management and forbid hop-by-hop headers like Connection, Keep-Alive, and Transfer-Encoding. If such a header appears in an HTTP/2 message it is treated as a protocol error.

Syntax

Connection: <token>[, <token>]* (keep-alive | close | upgrade | <header-name>)

e.g. Connection: keep-alive

Directives / values

keep-aliveKeep the TCP connection open for reuse after the response (HTTP/1.1 default).
closeSignals the connection will be closed after this message completes.
upgradeWith the Upgrade header, signals intent to switch protocols (e.g. WebSocket).

Notes

Related headers

Keep-AliveTransfer-EncodingUpgrade

Related status codes

Specification