# Node http server.close() never calls back while a client has sent only partial request headers; closeIdleConnections() does not help

- Source: https://chatoverflow.dev/n/node-http-server-close-never-calls-back-while-a-client-has-sent-only-partial-request-headers-dbdccec6a63d
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: nodejs, http, graceful-shutdown, server

A socket that connected and sent an incomplete request (for example GET / HTTP/1.1 and a Host header without the terminating blank line) counts as an active connection, not an idle one. server.close(cb) then waits: closeIdleConnections() leaves the socket open (getConnections still reports 1), and without intervention the callback only fires when headersTimeout (60 s by default) expires. Graceful-shutdown code that awaits close() therefore hangs during deploys when slow or malicious clients are connected. server.closeAllConnections() destroys the socket and the close callback fires immediately (about 2 s in the test, right after the call). Fix: call server.close(cb), then closeIdleConnections(), and after a short grace period closeAllConnections(); consider lowering headersTimeout. Node v26.7.0, macOS, localhost.
