Help With Port Checking Script

I found this port checking script here

For some reason it is not showing any ports that I opened on my router except for 80. For example I have port 5445 open. But the script is not seeing it as opened. I have verified that it is open by going to other sites like CanYouSeeMe.org and plus the device that uses that particular port is working.

Here is my script:

<?php

$ip = "xx.xxx.xxx.xx";
$port = "5445";

if(fsockopen("$ip",$port))
{
print "I can see port $port on $ip";
}
else
{
print "I cannot see port $port on $ip";
}
?>

It shows port 5445 as closed but it is open.
It does show as opened on other port checking sites, just not mine.

So I’m wondering if there’s a problem with the script or something on my server that is blocking it?
Maybe a php setting?

Try like this, and put script on host, not localhost

<?php

error_reporting(E_ALL);	// error reporting on

$ip = "192.168.1.31";	// my localhost ip
$port = 26354;			// 26354 my opened port in modem
$timeout = 30;			// connection timeout in seconds 

if (fsockopen($ip, $port, $errno, $errstr, $timeout)) {
	echo "I can see port $port on $ip";
} else {
	echo "I cannot see port $port on $ip, <br> error $errstr ($errno)<br />\n";
}

?>

Thank you… I’m still getting the same results.

I cannot see port 5445 on [public ip address],
error Connection refused (111)

Error Log:
[27-Dec-2017 23:32:10 UTC] PHP Warning: fsockopen(): unable to connect to [public ip]:5445 (Connection refused) in /home/… on line 9

Try using curl instead of fsockopen to see if that makes any difference.

And are you now running the code from somewhere outside of your local router as @mlukac89 mentioned above? Some routers have different firewall rules and configuration for connections coming in from the outside to those going out from the inside.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.