Score:0

cURL suddenly gives Connection Refused to an Ubuntu Server

us flag

I have a custom wordpress "client" plugin that makes a cURL call to a Node app on an Ubuntu server.

The call works perfectly from every WP installation, except for one where everything worked fine until yesterday then the following cURL call suddenly started to return a

Failed to connect to x.x.x.x port 3344 after 1040 ms: Connection refused.

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => 'http://x.x.x.x/wpdata/get',
      CURLOPT_PORT => 3344,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS =>'{
        "message" : "Some SHORT post data"
    }',
      CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json'
      ),
    ));


    if(! $results = curl_exec($curl) ) {
        die( curl_error($curl) );
    } 

The Node app uses Express, it's managed by PM2 and runs without nginx nor Apache, the clients connects directly using IP:PORT calls.

The server that hosts the Node app is an Ubuntu 18 server on a VM with fail2ban 0.10, but all the rules are actually disabled (even disabling fail2ban itself doesn't solve the problem).

Also iptables -L -n doesn't show any rule that could look like a ban for the failing server IP nor the listening port (afterall the same plugin on different client gives correct results).

Both /etc/hosts.deny and /etc/hosts.allow are empty too.

Getting mad after that, do someone knows where could I look to find why that single client gets a Connection Refused response?

Zareh Kasparian avatar
us flag
if you are not using NAT you may disable iptables for test purposes. Also my suggestion is to disable fail2ban. while having both disabled you may test they download manullay or telnet to the port manually to make sure destination server hasn't blocked your ip address.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.