Connection Header Explained

What the HTTP Connection header does and when it's used.

Published October 17, 2026

Connection controls whether the network connection stays open after the current transaction (keep-alive) or closes, and lists hop-by-hop headers.

How it works

In HTTP/1.1 keep-alive is the default. It is not used in HTTP/2.

The Connection header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
Connection: keep-alive
Where Connection appears.

Practical examples

The header

Connection: keep-alive

Set or use it in code

proxy_set_header Connection "";

Inspect it

curl -sI https://example.com | grep -i 'connection'

Common mistakes

  • Forgetting Connection: upgrade for WebSockets
  • Forwarding hop-by-hop headers through proxies
  • Closing connections too aggressively

Key takeaways

  • Connection: Connection controls whether the network connection stays open after the current transaction (keep-alive) or closes, and lists hop-by-hop headers.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

Does HTTP/2 use it?

No, it forbids connection-specific headers.

Is Connection case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles