Hi everyone, for some reason my node.js app is not able to connect to an IP address after I deployed it to digital ocean. My app is supposed to connect to physical alarm systems via IP/Port to get the system status (armed/disarmed).
UFW is currently inactive. My app is working locally. Is there something I need to configure in order to get it to connect from the digital ocean servers?

const client = new ElkClient({
    connection: { 
      host: "IP/DNS ADDRESS",
      secure: true/false,
      port: PORT,
      site: "SITENAME"
    }
  })

  console.log(client)
  client.connect().catch((err)=> console.log("Connection Error"))

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @michaelrbraun1985,

You can try and allow the port through your IPtables. I believe it will still need to be edited even if you are not using UFW.

First to allow incoming connections from this port (only if needed):

sudo iptables -A INPUT -p tcp --dport XXX -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport XXX -m conntrack --ctstate ESTABLISHED -j ACCEPT

Where you’ll need to change XXX with your actual port.

Now for outgoing connections, you’ll need to execute the following:

sudo iptables -A OUTPUT -p tcp --dport XXX -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A INPUT -p tcp --sport XXX -m conntrack --ctstate ESTABLISHED -j ACCEPT

Again change XXX with the actual port.

Just out of curiosity, which port are you trying to connect to?

  • Hi @michaelrbraun1985,

    Sorry for the second reply, I just got an idea after allowing the connections via IPtables. Try using telnet from your droplet. You can do it like so

    telnet XXX.XXX.XXX.XXX PORT
    

    Where XXX.XXX.XXX.XXX is the IP you are connecting to and PORT is the actual PORT you want to reach. When you execute this command what output do you see?

    Regards,
    KFSys