'what does "* Connection #0 to host example.com left intact" mean?

I'm using curl with curl -v https://example.com

and at the end it says * Connection #0 to host example.com left intact. What does that mean?



Solution 1:[1]

Adding a header "Connection: close" to your CURL command should solve the problem:

curl -v -H "Connection: close" https://example.com

Explanation can be found in this article:

Why is the connection left intact ?

The connection is left intact, because the server allowed it to stay open and CURL no need to close it after you receive the response for the request sent. That’s why the requests return ‘Connection: keep-alive‘ headers when you expect ‘Connection:close‘

If you wanted to close the connection, then you could send CURL request with ‘Connection: close‘ as shown below and you could see ‘* Closing connection 0‘ in the response.

I hope the article https://www.sneppets.com/software/connection-0-to-host-localhost-left-intact/ helps you solve your problem.

Solution 2:[2]

Short answer: it doesn't mean anything, when you just request one URL. After curl is finished and the process exits, the connection is not left intact anywhere despite the misleading message; it is closed just like you'd expect.

The connection is only reused if you fetch multiple URLs in the same curl invocation. In that case it's a good thing, and you shouldn't need to force the connection to close, unless you're debugging connection issues.

(I too went looking for answers, when I wanted to check that curl doesn't somehow keep the connection open in the background of my shell. It doesn't.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NelsonGon
Solution 2 Rennex