|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40234 Still can be PHP's fault.
Submitted: 2007-01-25 11:42 UTC Modified: 2007-01-26 15:49 UTC
From: silverbanana at gmx dot de Assigned:
Status: Not a bug Package: Network related
PHP Version: 6CVS-2007-01-25 (snap) OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: silverbanana at gmx dot de
New email:
PHP Version: OS:


 [2007-01-25 11:42 UTC] silverbanana at gmx dot de
gethostbynamel always returns false, instead of giving useful results. This is however only the case when I use PHP as CGI. gethostbynamel works as expected when I use PHP as Apache module and also when I use it from the command line, but not when I use it as CGI.

If this behaviour of gethostbynamel is intended or unavoidable, it should be mentioned in the manual for gethostbynamel.

Reproduce code:

Expected result:
List of addresses

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-25 11:45 UTC]
Please try using this CVS snapshot:
For Windows:

 [2007-01-25 12:05 UTC] silverbanana at gmx dot de
I just tested it with:
PHP Version 5.2.1RC4-dev Build Date:Jan 25 2007 12:17:41

And again it doesn't work with PHP-CGI, but it works with command line (Apache module not tested with this version).

Same result:
 [2007-01-25 12:42 UTC]
I tested with 'php-cgi -f test.php', where test.php contains your reproduce code, but I'm not able to reproduce this problem.
Please check the permissions of the user that is running the PHP CGI binary.
Also, are you running CGI alone (as I did) or from a webserver? And is it running in a different user account?
 [2007-01-25 13:16 UTC] silverbanana at gmx dot de
I've the same result as you when using PHP-CGI from command line. PHP-CGI from Apache runs as "NT-AUTORIT?T/SYSTEM", like Apache. So if this was the reason gethostnamel should also have failed when using it as module, but it didn't when I tested it with PHP6.

But when I use PHP-CGI with Apache it doesn't work. I somehow suspect that Apache and PHP communicate via some TCP/IP connection and that this interferes with gethostbynamel.

FYI, here just the two most important lines from my Apache configuration:
LoadModule fcgid_module modules/
FCGIWrapper "c:/Programme/Net/php5/php-cgi.exe" .php
Maybe I've just configured things wrong a bit, but I can't imagine that such a strange error could be the result of misconfiguration.
 [2007-01-25 15:43 UTC]
Please make sure your firewall does not block DNS requests issued by gethostbynamel().
Just disable the firewall for some time.

And please use 5.2, not PHP6.
PHP6 is in pre-alpha stage, which means it's a bit early to test it yet.
 [2007-01-25 21:52 UTC] silverbanana at gmx dot de
I justed tried to disable my firewall. It didn't make any difference. Besides, asking for the address of localhost shouldn't need any network traffic, should it? I mean, its written in hosts.
 [2007-01-25 22:01 UTC]
>I mean, its written in hosts.
Then the CGI binary should have enough privileges to read it.
 [2007-01-26 14:33 UTC] silverbanana at gmx dot de
It just came into my mind that other PHP functions will also need to resolve names. So I tried this one:
$a = file_get_contents("");

This results on PHP-CGI with Apache in:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt. in D:\path\file.php

So some Windows-API-function is failing.

Btw, hosts is world readable (I think that's the way it should be, right) on my system so that can hardly be the reason.
 [2007-01-26 14:44 UTC]
Not PHP problem.
 [2007-01-26 15:49 UTC] silverbanana at gmx dot de
Just because some Windows API doesn't return what we want doesn't mean PHP isn't responsible for that. I think it's quite interesting that PHP has it's problems when running as fastCGI under Windows. I just glanced at the source and found some interesting comment:
cgi_main.c,L1264: for windows, socket listening is broken in the fastcgi library itself so dissabling this feature on windows till time is available to fix it
I'm not sure what exactly was disabled, since fastcgi works so far, but there might be side-effects.
So I think it's worth to take a second look on that error.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Aug 09 10:05:43 2022 UTC