Unless you timestamp those log lines, I don't see any evidence that the DNS query is done when the godoc server shuts down. Could it not just be that after the 2 second sleep, when it's time to make a new connection, it finds that the pool is empty so has to do a lookup to establish a new connection?
I've tested this myself, using your code and apache running on the local server. $ go run httpclient.go http://localhost:80/ DNS Start Info: {Host:localhost} DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} Got Conn: {Conn:0xc000010070 Reused:false WasIdle:false IdleTime:0s} Put Idle Conn Error: <nil> Resp protocol: "HTTP/1.1" Sleeping now -------- Got Conn: {Conn:0xc000010070 Reused:true WasIdle:true IdleTime:2.000554686s} Put Idle Conn Error: <nil> Resp protocol: "HTTP/1.1" Sleeping now *<< at this point I "systemctl stop apache2" in another terminal >>* *<< nothing happens until the 2 seconds is up, and then I see: >>* -------- DNS Start Info: {Host:localhost} DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} Got error in making request: Get "http://localhost:80/": dial tcp 127.0.0.1:80: connect: connection refused Sleeping now -------- DNS Start Info: {Host:localhost} DNS Done Info: {Addrs:[{IP:127.0.0.1 Zone:}] Err:<nil> Coalesced:false} Got error in making request: Get "http://localhost:80/": dial tcp 127.0.0.1:80: connect: connection refused Sleeping now ^Csignal: interrupt So as far as I can tell, the client tries to re-use the existing connection from the pool, finds there isn't one (or it's broken), and therefore tries to establish a new connection - which of course requires a lookup of the hostname in the URL. Aside: I'd say the trace hooks "DNSStart" and "DNSDone" are somewhat misnamed, because the hostname resolution isn't necessarily done via DNS - in both your example and mine it's done via /etc/hosts. But the intention is clear. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/bb366eb5-c7df-452a-9549-281543b1b6d4n%40googlegroups.com.