Question

Connect to external IP address

  • Posted April 7, 2021
  • IPv6

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"))
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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?