Warning: fsockopen(): unable to connect to

itrends

Well-Known Member
Oct 21, 2004
50
0
156
Hello,


None of my users (including a few of my own sites) have the right to open a connection (fsockopen) to another server.

"Warning: fsockopen(): unable to connect to *** "

Why is this?
 

brainx

Member
Jul 9, 2003
23
0
151
Hi,

This probably is caused by your firewall configuration.You may need to allow both incoming and outgoing access for the ip and/or the port number you wish to connect to.

We had similar issues before and have solved them this way.Hope it helps.
Thanks
 

itrends

Well-Known Member
Oct 21, 2004
50
0
156
brainx said:
Hi,

This probably is caused by your firewall configuration.You may need to allow both incoming and outgoing access for the ip and/or the port number you wish to connect to.

We had similar issues before and have solved them this way.Hope it helps.
Thanks
no, our firewall does not have any rules against this. It allows all outbound traffic, inbound is filtered.

It has to do something with PHP, just can't figure it out?


Wieger.
 

richy

Well-Known Member
Jun 30, 2003
274
1
168
Are you able to connect using telnet from the server to the exact same remote server?
 

itrends

Well-Known Member
Oct 21, 2004
50
0
156
With SSH it all goes well.. telnet returns valid information.

It's only when i want to fsockopen() with a script.
 

webignition

Well-Known Member
Jan 22, 2005
1,876
1
166
From the PHP manual (http://pl2.php.net/manual/en/function.fsockopen.php):

If the call fails, it will return FALSE and if the optional errno and errstr arguments are present they will be set to indicate the actual system level error that occurred in the system-level connect() call. If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the connect() call. This is most likely due to a problem initializing the socket. Note that the errno and errstr arguments will always be passed by reference.
Try specifying the optional paramaters errno and errstr and then print them afterwards. This should give you more specific errors which should aid the troubleshooting process.

PHP:
$fp = fsockopen ("example.com/index.html", 80, $errno, $errstr, 30);
if ($fp === false) {
  print($errno." : ".$errstr);
}
 

itrends

Well-Known Member
Oct 21, 2004
50
0
156
webignition said:
From the PHP manual (http://pl2.php.net/manual/en/function.fsockopen.php):



Try specifying the optional paramaters errno and errstr and then print them afterwards. This should give you more specific errors which should aid the troubleshooting process.

PHP:
$fp = fsockopen ("example.com/index.html", 80, $errno, $errstr, 30);
if ($fp === false) {
  print($errno." : ".$errstr);
}
As i said, permission denied?
 

webignition

Well-Known Member
Jan 22, 2005
1,876
1
166
I suppose if you've exhausted all of the options presented here and you're still unable to resolve the problem, all I could suggest would be:

1. Thoroughly search the forums in case there is a thread on this that you missed
2. Use Google or some other search engine to hunt for solutions
3. Contact your data center for support
4. Hire someone if you're unable to resolve the issue yourself
 

itrends

Well-Known Member
Oct 21, 2004
50
0
156
done all that, nobody seems to know.. but i found someone with the same problem on the forum (also, no sollution?)