Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a ajax application that makes a request every 3 seconds, the requested page sets the header to (header("Connection: Keep-Alive, close");) then performs a database query and returns the latest data.

The value for TIME_WAIT is 60 seconds, so even tough I close the connection in my requested page(i.e "Connection: Keep-Alive, close"), the connection seem to be present for the next 60 seconds (this occurs for every Ajax request that I make), so for 1 minute 20 requests are made and total TIME_WAIT for that IP seems to be around 20

Is it possible to reduce the TIME_WAIT to say 15 seconds, to reduce the overall TIME_WAITS or is it possible to force a connection close after every Ajax request

Any help will be appreciated


share|improve this question

You can use net.ipv4.tcp_fin_timeout kernel parameter:

# sysctl net.ipv4.tcp_fin_timeout=15

Edit /etc/sysctl.conf, add to end

net.ipv4.tcp_fin_timeout = 15

then run:

# sysctl -p
share|improve this answer
thanks for your help – Akash Mar 2 '11 at 14:37

Connection: keep-alive, close is not valid HTTP 1.1, as exactly one connection-token is allowed, so I'd expect this header to be ignored and keep-alive to be active nonetheless; in HTTP 1.0, the "Connection" tag means something completely different.

There should be no technical difference whether the connection is "recycled" or not, and you should leave that choice to the browser. Playing with FIN timeouts is almost never a good idea.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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