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 just asked this question on stackoverflow, and it was recommended that I also ask here.

I have a PHP application that uses the ODBC functions for database access. My DBA recently discovered that the application is not closings its database connections, resulting in numerous invalid connections that are in a TIME_WAIT state.

We have checked the code and I am doing an odbc_close_all call in every script, plus even if I wasn't then the connection should close at the end of the script anyway. There are no long running scripts holding on to their connections

Has anyone seen anything like this or have any idea what the issue might be?

PHP version is 5.1.4

Running on Windows Server 2003 R2 Service Pack 2

MySQL database

share|improve this question
Sorry, I forgot to ask this over at stackoverflow: You have a MySQL server but yet you're using php-odbc (and thus the mysql-odbc connector). Is this necessary? All three mysql-related php modules (mysql, mysqli, pdo-mysql) are e.g. able to use unix socket/named pipes instead of tcp/ip socket to connect to the MySQL server. – VolkerK Aug 19 '10 at 17:02
The application connects to two different databases, one of which is MySQL and and the other is Cache. The Cache database can only be connected to via ODBC, and the original developer decided to just use ODBC for both to be consistent. – wshato Aug 19 '10 at 19:16

After much research, we stumbled upon several sources that inidcated that he issue was TcpTimedWaitDelay (thanks VolkerK for the tip). This has helped a good deal, but we are still seeing about 30-40 connections in the TIME_WAIT state at any given time.

We are wondering now if anyone has any advice as to whether this behavior is normal for a Windows Server and if this is as good as it gets, or if there are other avenues worth researching.


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.