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 am trying to test a website on a local machine that has Windows 7 installed. I want to use named pipes to connect to the MySQL server, but mysql_connect() seems to throw an error:

[2002] No connection could be made because the target machine actively (trying to connect via tcp://localhost:3306)

For some reason it's still using TCP. I'm testing with a simple PHP (5.3) script:


mysql_connect("localhost", "root", "password") or die();

echo "It works!";


The MySQL client works fine. It's just a problem with PHP (note: using TCP instead works).

This is what I have in my.ini:





I tried setting these variables in php.ini:

pdo_mysql.default_socket = mysql
mysql.default_socket = mysql
mysqli.default_socket = mysql
share|improve this question
Well, I'm used to work with CentOS/RHEL desktop/server, and never get this error before. I know that php and mysql tend to get error on windows 7. Did you try your code on another computer? Xp? linux? Maybe the problem is from your 7. – Anarko_Bizounours Jun 27 '11 at 11:02
@Anarko_Bizounours I've never tried with named pipes. Here it says that specifying the host name as . forces the use of named pipes in Windows, but I get "no such host is known". It still seems to be using TCP (trying to connect via tcp://.:3306). – someguy Jun 27 '11 at 11:15
By all that's holy, don't use bare mysql_*. Use mysqli or PDO. – Shadur Dec 11 '14 at 8:11
up vote 0 down vote accepted

This appears to be a bug affecting the VC9 binaries. See: (if the link doesn't work, try this cached version). According to

A patch is being worked on.

Support will be in the next minor PHP version, be it 5.4 or something else.

5.3.x won't get this, as this is classified as new feature.

As the person that asked this question, I'd like to mention that I was using the Apache web server. The PHP downloads page for Windows does say that VC9 binaries should not be used with Apache (I was not aware at the time), but this seems to be a separate issue, since IIS users also had the same problem, if you look at the bug report.

share|improve this answer
To clarify something (since you have read just first part of 2-sentenced message): The PHP downloads page for Windows says: Do NOT use VC9 version with binaries. VC9 versions of Apache can be fetched at Apache Lounge. We use their binaries to build the Apache SAPIs. – LazyOne Jun 27 '11 at 21:11
@LazyOne Yes, when I said VC9 binaries should not be used with Apache, I meant the binaries, not Apache, sorry. I was just pointing out that this is a separate issue. – someguy Jun 28 '11 at 10:09

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.