I am setting my ubuntu web server up and I am setting up a firewall on it. All is good except for my one document that has file_get_contents() up. I am just wondering what port i need to unblock for this to work.
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/site/videos.php on line 65
That is the warning I get from the file. Im sure it's a port issue because if there all unblocked, it works just fine. Any help would be great!
Code for file_get:
$xml = simplexml_load_string(file_get_contents('http://gdata.youtube.com/feeds/api/users/TomSka/uploads'));
To change the firewall setting as detailed in the link and it will works. Please refer below document
http://www.radiotope.com/content/safari-and-sonicwall
The setting was "Enforce Host Tag Search with for CFS"
Weirldly it only seems to affect fgets on PHP 5 running on Linux other platforms and other PHP generated HTTP requests are unaffected.
Related
I'm trying to follow this tutorial:
http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
But, for love nor money, I couldn't get a response out of the console.
I loaded up the startDeamon manually and found it was failing to bind to my (local) host.
Warning: socket_bind() [function.socket-bind]: Host lookup failed [-10001]: Unknown host
My local server is running on http://localhost:33. I have specifying my host as both localhost and 127.0.0.1, with and without http, and with and without specifying the port, but no joy.
Can anyone help me out?
Thanks in advance
Try using port 12345 instead of 33.
remove the http:// part and just try access it as localhost
you cannot use localhost, or 127.0.0.1 when dealing with sockets, but need to use the domain/host name or host IP address instead. It is explained as a user experience in the PHP5 manual section
My project uses PHP JavaBridge, I have installed WAMP, JRE 6.0, and Tomcat 6.0.32
I can now access http://localhost:8080/ successfully but when I run my PHP site it gives me the following error
warning: fsockopen() [function.fsockopen]: unable to connect to localhost:8080 (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. )
Can anyone please help me with this issue?
EDIT
Forgot to mention that I am using Windows 7
My comment above worked as a solution and hence this answer, so that in future others get it.
Can you 127.0.0.1:8080 instead of localhost:8080? See what do you get?
fsocketopen takes the hostname and it should be a valid domain, in your case, (in general) it could be a valid domain as long as you have an entry for localhost in your hosts file (C:\Windows\System 32\drivers\etc\hosts). See if you have something similar to that.
I got the following error when I get contents from file("http://www.otherdomain.com").
file() [function.file]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
The domain server is linux.
How to resolve this problem?
Quoting:
If you're having problems with fopen("url...") but you can run 'host
url' in a shell window and get the
correct lookup, here's why...
This has had me banging my head
against it all day - finally I found
the answer buried in the bug reports,
but figured it should really be more
prominent!
The problem happens when you're on an
ADSL line with DHCP (like our
office)... When the ADSL modem renews
the DHCP lease, you can also switch
DNS servers, which confuses apache
(and hence PHP) - meaning that you
can't look up hosts from within PHP,
even though you can from the
commandline.... The short-term
solution is to restart apache.
You'll get "php_network_getaddresses:
getaddrinfo failed: Temporary failure
in name resolution in ..." messages as
symptoms. Restart apache, and they're
gone :-)
Simon
Comment by Simon at php.net
make sure that website can be reached from you server.
also make sure that you are using has a proper DNS server setup.
if you are sure that website is working ... try modifying the /etc/hosts file and add the website's IP for test purposes, then try to figure out why it doesn't solve the domain.
The Domain can not be resolved to it's IP address.
If you have your DNS running local, try restarting it. If not, check your DNS or add a different server to /etc/resolve.conf (i.e. nameserver 8.8.8.8).
You can also add the domain as a static entry in your hosts file:
On your linux server add the DNS information to your /etc/hosts file using:
echo '127.0.0.1 www.otherdomain.com' >> /etc/hosts
…where 127.0.0.1 is the IP address of your website and www.otherdomain.com the domain name your using.
You can find the IP address of any domain using nslookup, i.e
nslookup www.otherdomain.com
I was running into this issue with CiviCRM geocoding! Restarting Apache like Shehi recommended fixed the problem.
check your internet connection. If the internet is down, this error occurs.
Sample code:
$html = file_get_contents('http://www.google.com');
echo $html;
It works on localhost. But after uploading to the webserver, it gives me a warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution. If I replace the domain name with google's IP address, it gives a warning: failed to open stream: Connection timed out.
And ini_get("allow_url_fopen") return 1.
===
Edit: Probably it is a server problem. I guess this question should be asked on serverfault.com.
Your host is most likely refusing the outbound connection. It's the only thing I can think of.
This is a known bug in some versions of PHP. Tell your host about the problem and ask them to upgrade PHP.
It's also possible that your host have extremely naive firewall rules in place blocking just about any networking you try to do. Which host is it?
I am using the file_get_contents function to get the URL into a string:
$contents = file_get_contents("http://google.com");
But, I am getting the following error:
file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known.
How can I solve this in my localhost?
Your "localhost" cannot resolve the name google.com to an ip address, which means your machine doesn't/can't reach a valid dns server.
This probably doesn't only affect php. Try ping google.com on the console of that machine. Does this complain about the unknown host, too?
The steps necessary to solve the problem depend on what your "localhost" is (operating system, flavour/distribution, ...) and how it is connected to the internet.
It is because you need to turn on allow_url_fopen in php.ini
Check your localhost and username.
Like if you are using Xampp, in the host column type Localhost
and the database name
and last but not least the username with root, and then install.
It's quite easy but if you missing it, it's gone be very upsetting.