Bug #74483 [Com]: stream_socket_client fails without hosts entry

From: Date: Thu, 20 Apr 2017 20:35:08 +0000
Subject: Bug #74483 [Com]: stream_socket_client fails without hosts entry
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208695@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74483&edit=1 ID: 74483 Comment by: spam2 at rhsoft dot net Reported by: imacarthur at moditcms dot com Summary: stream_socket_client fails without hosts entry Status: Open Type: Bug Package: Apache related Operating System: Fedora 25 PHP Version: 7.0.18 Block user comment: N Private report: N New Comment: > Always works from the command line. It's only from within > Apache I see the issue. Multiple sites [maps.googleapis.com, > fedex.com, even google.com] have the same issue and how is that a PHP issue? you apache environment runs in some weird chroot and can't resolve DNS names - fix your setup Previous Comments: ------------------------------------------------------------------------ [2017-04-20 20:28:53] imacarthur at moditcms dot com Description: ------------ Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/vhosts/vitatree/test.php on line 9 Warning: stream_socket_client(): unable to connect to ssl://pilot-payflowpro.paypal.com:443 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/vhosts/vitatree/test.php on line 9 errno :0 message: php_network_getaddresses: getaddrinfo failed: Name or service not known If I add an entry in /etc/hosts for the site it works. Always works from the command line. It's only from within Apache I see the issue. Multiple sites [maps.googleapis.com, fedex.com, even google.com] have the same issue. The name won't resolve without an entry in /etc/hosts. php test.php - works wget //hostname/test.php - fails Actual php version is 7.0.17 Linux ingagedigital.com 4.9.13-200.fc25.x86_64 #1 SMP Mon Feb 27 16:48:42 UTC 2017 x86_64 Apache/2.4.25 (Fedora) OpenSSL/1.0.2k-fips PHP/7.0.17 mod_perl/2.0.10 Perl/v5.24.1 Test script: --------------- <?php $context_opts = array(); $context = stream_context_create($context_opts); $fp = stream_socket_client( "ssl://pilot-payflowpro.paypal.com:443", $errno, $errmsg, 1000, STREAM_CLIENT_CONNECT, $context); echo "errno :".$errno." message: ".$errmsg.PHP_EOL; ?> Expected result: ---------------- errno :0 message: Actual result: -------------- Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/vhosts/vitatree/test.php on line 9 Warning: stream_socket_client(): unable to connect to ssl://pilot-payflowpro.paypal.com:443 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/vhosts/vitatree/test.php on line 9 errno :0 message: php_network_getaddresses: getaddrinfo failed: Name or service not known ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74483&edit=1

« previous php.bugs (#208695) next »