Skip to main content

Connection

BothActive

The Connection header controls whether the TCP connection stays open after the current request completes. 'keep-alive' (default in HTTP/1.1) reuses the connection for subsequent requests, avoiding TCP handshake overhead. 'close' tells the server to close the connection after the response. In HTTP/2, Connection is forbidden – the protocol handles multiplexing internally.

Connection: keep-alive | close

Description

Connection is a hop-by-hop header that controls connection persistence. HTTP/1.0 closed connections by default – keep-alive was an extension. HTTP/1.1 made keep-alive the default. HTTP/2 banned Connection (and other hop-by-hop headers) entirely because its binary framing handles connection management internally.

Directives

DirectiveDescription
keep-aliveReuse the TCP connection for subsequent requests. Default in HTTP/1.1.
closeClose the TCP connection after the response is sent.

Examples

HTTP/1.1 keep-alive
http
HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: timeout=5, max=100
Force close
http
HTTP/1.1 200 OK
Connection: close

Related

Specification

RFC 9110Connection specification →