Bug #52434 [Com]: mysqlnd: host cannot be "localhost" when connecting to tcp port

From: Date: Thu, 14 Mar 2013 12:34:40 +0000
Subject: Bug #52434 [Com]: mysqlnd: host cannot be "localhost" when connecting to tcp port
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-177784@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52434&edit=1

 ID:                 52434
 Comment by:         45net at rambler dot ru
 Reported by:        anthon dot pang at gmail dot com
 Summary:            mysqlnd: host cannot be "localhost" when connecting
                     to tcp port
 Status:             Not a bug
 Type:               Bug
 Package:            MySQL related
 Operating System:   Ubuntu 10.04
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

Confirmed. PHP 5.3.22 compiled with mysqlnd enabled both on mysql and mysqli ( and even on pdo).
127.0.0.1 works, localhost doesn't.


Previous Comments:
------------------------------------------------------------------------
[2012-10-10 18:21:47] register at bazanov dot net

Athon!
Thank you very much for bringing this BUG out!
I killed 1-2 hours of my time trying to understand why I can't connect to the server.
Then I found this bug report and changed localhost to 127.0.0.1 and it worked!

This is one of the most annoying and frustrating bugs ever. It must be fixed!

For search engines, here is the error I got:
Warning: mysqli_real_connect() ... [2002] ... connection refused. (trying to connect via
tcp://localhost:3306)
Warning: mysqli_real_connect() ... (HY000/2002) ... connection refused. (trying to connect via
tcp://localhost:3306)

------------------------------------------------------------------------
[2010-09-17 04:59:19] neweracracker at gmail dot com

I agree with anthon.

Someone has to fix this :)

------------------------------------------------------------------------
[2010-09-17 04:15:28] anthon dot pang at gmail dot com

This doesn't have anything to do with the hosts file or DNS resolution.

mysqlnd (rightly or wrongly) specially interprets "localhost" to mean a local 
socket, to mimic some of the behavior of MySQL command-line utilities.

------------------------------------------------------------------------
[2010-09-17 03:50:57] neweracracker at gmail dot com

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

Its disabled :)
Still no result hmm.

I blame Microsoft for this. lol

------------------------------------------------------------------------
[2010-09-16 23:30:01] pajoye@php.net

There are dozen of reports about that on Windows and it is unrelated to this problem.

A work around for the windows issue will be present in 5.3.4, in the meantime you can disable ::1 in
your windows' host file.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=52434


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=52434&edit=1


Thread (12 messages)

« previous php.bugs (#177784) next »