lingering_timeout

Sets the timeout period for lingering close on connections.

Syntaxlingering_timeout seconds;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The lingering_timeout directive in NGINX configures the duration (in seconds) that the server will wait after a client closes a connection before completely closing the socket. This is particularly useful for scenarios where the server wants to allow additional read or write operations to complete without dropping the connection immediately. When a connection is in a lingering state, the server will keep the socket open for the specified timeout duration to give the client time to send or receive any remaining data. If the timeout expires without any further activity, the connection is forcibly closed.

Setting a lingering_timeout is useful in high-load environments where connection management is critical, as it can help reduce the number of abrupt connection terminations. This directive can be applied in various contexts: http, server, and location, allowing granular control over how connections are handled across different sections of an NGINX configuration.

When specifying the timeout, it is important to note that the value should be a positive integer representing seconds. Values that are too short may lead to frequent connection terminations, whereas values that are too long could tie up system resources unnecessarily.

Config Example

http {
    lingering_timeout 10;
}
server {
    lingering_timeout 5;
}
location / {
    lingering_timeout 3;
}

Setting lingering_timeout to a very low value may lead to abrupt disconnections, particularly in high-latency environments.

Values set too high can lead to resource exhaustion as open connections remain idle for extended periods.

← Back to all directives