Error on my website "connection refused"

hi there so i also have the website
however the server status widget wont load the server stats…
it comes up with connection refused or timed out on line 39

line 39 is…

$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 1)

please help as i have no idea where to go from here!


you are only allowing 1 second, try changing it to 30.
[php]$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 30);[/php]

and don’t forget the semi-colon at the end. (missing from your OP).

Red :wink:

hey thanks for the help but its still wont connect! <?php

  • @Třída serveru

class Server

public $host;
public $port;

public function __construct($host, $port = 25565)
$this->port = (int)($port);

if(preg_match('/:\d+$/', $host)) {
		if(preg_match('/:\/\//', $host))
			list($protocol, $this->host, $this->port) = explode(':', str_replace('//', '', $host));
			list($this->host, $this->port) = explode(':', $host);
		$this->host = $host;


public function info()

$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 45);

	$stats = array(
	if (!$header)
		return $stats;

	fwrite($header, "\xfe\x01");
	$info = fread($header, 1024);

		return $stats;

	$info = substr($info, 9);
	$info = mb_convert_encoding($info, 'auto', 'UCS-2');
	$info = explode("\x00", $info);

	$stats['online'] = true;
	list($stats['protocol'], $stats['version'], $stats['name'], $stats['players'], $stats['max']) = $info;

	return $stats;


thats the entire code,
it still just says connection refused, the website is and its for a minecraft server, any help would be appreciated :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service