Connection refused when I do Curl to a service

Asked

Viewed 206 times

0

I have a service/API that runs on xampp, xampp is installed on a Windows server. From the moment I started to hear the door 1500 instead of the 80 in the xampp, I started to have some problems.

There are 2 situations relevant for analysis.

  1. When I call the service, via website hosted in CPANEL. I get refused Connection.
  2. When I use the same call code on a personal computer. I receive the desired data in the Curl, I get the connection and everything is fine.

Step to show the code used:

    // where are we posting to?
    $url = 'http://dns_para_minha_API_alojada_servidor_windows_correndo_xampp_apache_http_server:1500/ncsync/Sync/getDossierProdutos?ndos=' . $ndos . '&nReg=' . $nReg;

    // open connection
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER,    1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    // execute post
    $result = curl_exec($ch);
    // close connection
    curl_close($ch);
    return $result;

Both in the CPANEL, as the server, and in the personal computer, I have the Curl installed (confirmation through the phpinfo instruction()). Nota: cURL executados no CPANEL, para outas APIs, como a da "google" funcionam.

1 answer

1


This can probably be a firewall lock, preventing you to use the port 1500.

The Cpanel comes with a lot of features, one of them is the firewall, you can see how to open the doors in the documentation of the Cpanel itself:

You must authorize IP/Port in CSF (Home >> Plugins >> Configserver & Firewall) and on iptables (perform a iptables -I INPUT -p tcp -m tcp --dport 1500 -j ACCEPT).

If this server is shared, maybe refer to the administrator/provider to do this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.