0

tried everything... port 8008 seems to be open but no luck. netstat shows 8008 to be listening

I can do curl localhost:8008 but not from an external machine using the ip address of my server

and yes, i want to host my nodejs on port 8008 (not 8080 - im using 8080 for something else)

netstat output:

tcp 0 0 0.0.0.0:8008 0.0.0.0:* LISTEN

jj-23
  • 1
  • From your netstat line it looks like your node.js server is running correctly. Have you checked your firewall? What does `sudo iptables -L` report? – slebetman Jul 06 '20 at 05:47
  • Also, what server is this? On services like AWS there is another level of firewall that you must set up using the website – slebetman Jul 06 '20 at 05:47
  • I’m using oracle cloud. I’ll look into firewall settings outside of the server – jj-23 Jul 06 '20 at 16:29
  • Thank you. The issue was the firewall setting of the oracle server itself. Issue resolved – jj-23 Jul 06 '20 at 18:12
  • 1
    @jj-23, I'm facing exactly the same issue on the Oracle Cloud server. I cannot find where to exactly disable the firewall setting on the oracle server itself. Can you point me in the right direction? – Amber Elferink Feb 10 '21 at 22:14
  • 1
    @AmberElferink i added a rule to the firewall to allow traffic to the port you have to login to your oracle cloud dashboard (https://cloud.oracle.com/) then go to Networking > Virtual Cloud Networks: select the server youre trying to update go to the Public subnet then select the Security you are using then add an Ingress Rule specifying the port you want to open – jj-23 Feb 13 '21 at 03:34
  • 1
    Thanks @jj-23, I just found out last night indeed how to do it. Same idea but I did it a little differently (for future people struggling). I went to Compute > Instances and clicked on my instance name. Then in the large overview, click subnet, and add ingress rules there. I have a more clear guide now on: https://stackoverflow.com/questions/66146781/vps-nodejs-server-not-accessible-on-public-ip-oracle-compute-cloud – Amber Elferink Feb 13 '21 at 13:53

1 Answers1

0

Have you tried changing your port

var port = process.env.PORT || 8008;   //server.listen(3000, '0.0.0.0');
app.listen(port, 0.0.0.0, function() {
  console.log("Listening on " + port);
});

If you have .env insert value PORT=8008

and run your server

xMayank
  • 1,875
  • 2
  • 5
  • 19
  • im getting this error when i use my server's public ip: Error: listen EADDRNOTAVAIL: address not available XXX.XX.XX.XXX:8008 at Server.setupListenHandle [as _listen2] (net.js:1296:21) at listenInCluster (net.js:1361:12) – jj-23 Jul 06 '20 at 05:21
  • Updated my answer check now. – xMayank Jul 06 '20 at 05:35
  • thanks. i think you meant to '0.0.0.0' - ive tried that "app.listen(port, '0.0.0.0', () => {..." but still no luck. nodejs seems to work if i use port 8080 – jj-23 Jul 06 '20 at 05:40
  • no errors. the app starts fine with port 8008. I can do curl localhost:8008 when inside the server. But when i access the app outside the server, the connection is timing out – jj-23 Jul 06 '20 at 05:49
  • You are accessing app from same network or outside network ? – xMayank Jul 06 '20 at 05:50
  • outside the network. im trying to access it using the public ip of my server – jj-23 Jul 06 '20 at 05:56