Question

Connect to external IP address

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

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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?