Connection refused

Hi again.
Now I have this error, and I want to know if its the configuration of the server I am working or Slim configuration.
So my API is running in a server in localhost:8080, i was told, in order to access my API outside my server, i should write xxx.xxx.xxx:8080 And i did tried it like this. (I start the API with this command php -S localhost:8080 -t public public/index.php)

$http({
url:'http://xxx.xxx.xxx.xxx:8080/login',
method:"POST",
data:{user:$scope.user, password:$scope.password}
})

In my API the code is like this.

$app->post('/login', function ($request, $response) {
//Parametros que se pasan a la api
$input  = $request->getParsedBody();
 $req = $input['usuario'];
 $md5pass = md5($input['password']);
$sth = $this->db->prepare("query");
//bindParam pasandole los parametros para evitar injecciones sql
$sth->bindParam("password", md5($input['password']));
$sth->bindParam("usuario", $input['usuario']);
$sth->execute();
$todos = $sth->fetchAll();
$cliente_id = $todos->cliente_id;
 ....

But i get this error when trying to call xxx.xxx.xxx:8080/login

'OPTIONS http://xxx.xxx.xxx.xxx:8080/login net::ERR_CONNECTION_REFUSED'

Any clue why I am getting this error and how to solve it.
Thanks in advance for your time.

Most likely server configuration, not Slim. Perhaps your firewall isn’t allowing connections, or not allowing connections to that port. Or that application (presumed Apache) isn’t allowed to accept incoming connections.

If you are on a Mac, you can use the Network Utility (in Applications/Utilities) to check if the port is open and connectable from the remote machine. Go to the Port Scan tab, put in the IP of your server, and test only port 8080. See if it is open.