When the client uses the Connection: close header in the request message, this means that it wants the server to close the connection after sending the response message.

I thought that this header is only used in the request messages, but I have noticed that it is also used in the response messages. For example:

enter image description here

What does this header means when used in the response message?

I think that it means that the server will close the connection after sending the response the message (even if the client has used the Connection: keep-alive header in its request message). Am I correct?

1 Answer 1


Yes, this is correct. The server can just say "I don't support your keep-alive request and will just close the connection when I am finished".

From RFC 2616, Section 14.10:

HTTP/1.1 defines the "close" connection option for the sender to
signal that the connection will be closed after completion of the
response. For example,

   Connection: close

in either the request or the response header fields indicates that the connection SHOULD NOT be considered `persistent' (section 8.1)
after the current request/response is complete.

HTTP/1.1 applications that do not support persistent connections MUST include the "close" connection option in every message.

  • 4
    That's weird IMO, why to say that the connection will be closed, if server can simply close it? Shouldn't client then just see it that the connection was closed by the server. Any idea what was the point in this header? I don't see any value here.
    – Pavel P
    Nov 24, 2018 at 5:43
  • 3
    @Pavel The web application includes the "Connection: close" http header in the response in cases where it want's to inform the front-end load balancer to close the keep alive connection incase the load balancer is using one.
    – Basil A
    Mar 12, 2019 at 13:59
  • 1
    @BasilA so that load balancer closes connection to the server or to the client? IMO load balancer could see that the connection was closed by the server and would know that without reading any headers. Also reverse is true: server can close connection without the Connection: close header
    – Pavel P
    Mar 13, 2019 at 23:05
  • 2
    @Pavel The loadbalancer usually receives multiple connections from multiple clients and utilizes the same connection with the backend by using multiplexing through a keep-alive connection. When some backends might not want to be part of this multiplexing, the backend http response should include a "Connection: close" to inform the load balancer to close it's connection and stop multiplexing. This is described in detail in AWS Load Balancing Guide (Scroll down to 'HTTP Connections') docs.aws.amazon.com/elasticloadbalancing/latest/userguide/…
    – Basil A
    Mar 14, 2019 at 8:20
  • 5
    @BasilA Looks like you're right. Interesting. The Connection general-header field allows the sender to specify options that are desired for that particular connection and MUST NOT be communicated by proxies over further connections.
    – Daniel F
    Sep 5, 2019 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.