Edit report at http://bugs.php.net/bug.php?id=45150&edit=1

 ID:               45150
 Updated by:       paj...@php.net
 Reported by:      conor dot kerr_php at dev dot ceon dot net
 Summary:          MySQL functions cannot be used with 5.3.x on Vista
                   when using "localhost"
-Status:           Closed
+Status:           Bogus
 Type:             Bug
 Package:          MySQL related
 Operating System: Windows Vista
 PHP Version:      5.3CVS-2008-07-23 (snap)

 New Comment:

That's not a bug, please refer to the dozen other reports about that.


Previous Comments:
------------------------------------------------------------------------
[2010-03-05 20:46:38] changeorders at gmail dot com

Fresh install of PHP 5.3.x on Server 2008. Same problem. Had to comment
out the IPv6 entry for localhost in the hosts file. This is still a bug.

------------------------------------------------------------------------
[2008-07-23 13:27:36] conor dot kerr_php at dev dot ceon dot net

Okay,



I've looked into this further and tested with PHP5.2.6 on the same setup
and get the same problem.



I've seen a few bugs in the database which refer to this same
localhost/127.0.0.1 issue.



I agree that it's not a PHP issue.



However, it will become a serious enough issue for people when they move
to 5.3 from a previous version as many PHP-based open source software
packages use "localhost" as their default database server host.



A lot of people will waste a lot of time unless it is made prevalent
somewhere that:



"127.0.0.1" should be used instead of "localhost" on Vista



OR: 



the line "::1  localhost" should be commented out in the hosts file for
Vista: "#::1  localhost"



Where is the best place to put this information? At the very least, it
should be part of the upgrade notes for 5.3 as, I'm willing to bet, many
PHP developers haven't previously used streams and this issue will not
have affected them until they upgrade to 5.3, at which point MySQL will
constantly time out on them because it does use streams and therefore is
susceptible to this windoze bug.



Hopefully there are no "Badly configured OS is not a PHP bug ->
Bogus"-type replies to this, that would not be helpful for the PHP
community at large!



This information needs to be made prevalent somewhere regarding 5.3.



Thanks,



I hope I've been of help to some others!



All the best...



Conor

http://ceon.net

------------------------------------------------------------------------
[2008-07-23 13:03:04] conor dot kerr_php at dev dot ceon dot net

Hi Andrey,



Thanks for replying. You have found the problem!



Running the following test script:



<?php



$httpfile  = file_get_contents("http://127.0.0.1/foo.txt";);



print "File contents read using 127.0.0.1: \n\n" . $httpfile . "\n\n";



$httpfile  = file_get_contents("http://localhost/foo.txt";);



print "File contents read using localhost: \n\n" . $httpfile . "\n\n";



?>



Gives the following results:



---

File contents read using 127.0.0.1: This is the content of foo.





Warning: file_get_contents(http://localhost/foo.txt)
[function.file-get-contents]: failed to open stream: A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in
E:\_CEON\Web\test\php_streams.php on line 7



Fatal error: Maximum execution time of 60 seconds exceeded in
E:\_CEON\Web\test\php_streams.php on line 7

---



So PHP 5.3 can't resolve localhost to 127.0.0.1 on Vista.



Should I update this bug to show that it is a streams problem?



Or close this bug and start a new one for Vista + Streams in 5.3?



Thanks again for the reply.



All the best...



Conor

------------------------------------------------------------------------
[2008-07-23 11:24:54] and...@php.net

Hi,

mysqlnd uses the PHP streams, compared to libmysql, which does the
network i/o itself. Thus, if mysqlnd can't resolve localhost to
127.0.0.1, then PHP should not be able too. Could you try to reproduce
that. mysqlnd does nothing special, just uses IPv4 to open a TCP
connection.

------------------------------------------------------------------------
[2008-07-18 16:54:54] conor dot kerr_php at dev dot ceon dot net

Hi,



Finally got this sorted.



Took a more methodical debugging attitude to this and reduced the
mysql.connect_timeout to 5 seconds.



Started to get error messages at last - so the mysql_connect function
that wasn't failing altogether.



Quickly determined that on Vista SP1, PHP5.3 can't resolve "localhost"
to "127.0.0.1" in the mysql_connect function.



Stopping Apache, pointing LoadModule php5_module ... and PHPIniDir ...
back to 5.2.x then restarting Apache allows the mysql_connect function
to work again (as expected).



This is using a stock hosts file on Windoze, which is correctly set up
for localhost.



I'm not sure where the bug is but could it possibly be something to do
with IPv6? Does PHP5.3's new mysqlnd default to using IPv6 first which
then isn't resolving properly to 127.0.0.1? I only ask that as 5.2.6
works perfectly on the same machine(s) and the only difference I can see
is the use of mysqlnd.



I could be barking up the wrong tree altogether though, but I can
confirm that PHP5.3.x can't resolve localhost when connecting to MySQL
on Vista whereas it can on XP and 5.2.6 never has any troubles on the
same machines (without any reboots).



Also, FYI, hadn't tried this procedure before because command line
commands to mysql work using "localhost" as well as "127.0.0.1" (as
would be expected if Apache+PHP5.2.6 also worked) so it never occurred
that there could be problem resolving localhost.



At least I've got a solution for anyone out there... replace "localhost"
with "127.0.0.1" in your scripts... until anyone @php.net can help us
out with a fix/answer of course!



Thanks again Jani for the post, it at least encouraged me to try and
debug this more methodically and now I don't have to reboot into OSX or
XP or upload scripts to a Linux server to out the new namespace
functionality! :)



All the best..



Conor Kerr

http://ceon.net

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


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

    http://bugs.php.net/bug.php?id=45150


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

Reply via email to