API external connection

Greetings community,

I’m trying to connect remotely with the api but I can not connect.

These are the connection data

It’s in Laravel.
protected function connection()
{
if (Auth::check())
{
$id = Auth::user()->id;
$mikrotik = Mikrotik::where(‘user_id’, $id)
->first();

try {
$this->client = new RouterOS\Client($mikrotik->ipaddress, $mikrotik->user, $mikrotik->pass,$mikrotik->port);
} catch (\Exception $e) {
print “Error connecting to RouterOS”;
}
}else{
echo ‘no logeed’;
}

}.

Excuse my English, I am the translator.

You probably need to enable PHP to make outgoing connections in the web server’s firewall.

If you’re on a web hosting plan, chances are you can already make outgoing connections to port 80 (HTTP), 443 (HTTPS) and 23 (FTP). Try to change the API port to this one, and connect with that instead. If it works, that’s certainly the cause, and you only need to add 8728 to the whitelist if you need to use those ports too.