Opening port 3000 EC2 Amazon web services

30,773

Solution 1

sudo netstat -tulpn doesn't show it as an open port.

netstat command will show what all ports that are being listened by "some" process. So in this case as you have mentioned, It seems like you application is not listening on port 3000.

First, fix your application and ensure that it is listening on port 3000.

Also, netstat has nothing to do with whether a port is opend/closed from firewall perspective. It will tell you whether a given port is in LISTENING mode by some process.

Follow these steps:

  1. Make sure your application is listening on port 3000: netstat -anp | grep 3000 also telnet 127.0.0.1 3000
  2. Then make sure that local firewall is configured to allow incoming access to port 3000 OR disable local firewall to do a quick test (service iptables stop). for linux, its usually iptables
  3. Allow incoming access to port 3000 in your AWS security group.

Please follow above 3 points and let us know if you still face the same issue.

Solution 2

in addition to all the steps above, check if you have ufw (uncomplicated firewall) set up.

to check if you have ufw running do:

sudo ufw status

if it is running, to allow port 3000 simply do the command

sudo ufw allow 3000

this solved the problem for me. i forgot that i had setup ufw a while back, and recently starting using my aws instance again.

Solution 3

I guess you made your changes using the AWS Management console. But this just means that Amazon's system will allow message on port 3000 through their own security systems to your server.

Your EC2 server (you don't say whether it's Windows or Linux) may have its own firewall system that you have to open port 3000 on. You will have to look at the documentation for your server to what settings you need to change.

I assume you've tried opening a browser on your EC2 instance and you can access the webapp from there.

Also, thinking laterally, if there are no other web servers running on your EC2 server why not change your node.js webapp to use port 80?

Solution 4

Had similar problem, but I was using socketio with SSL

var https = require('https').Server({
    key: fs.readFileSync(path.join(__dirname + '../) + 'ssl.key', 'utf8'),
    cert: fs.readFileSync(path.join(__dirname + '../') + 'ssl.crt', 'utf8')
}, app);

But the keys were wrong, so even though my AWS security was done, iptables clear and nginx providing with client js file, the request kept closing. So in Firefox I got net::ERR_CONNECTION_CLOSED and finally figured out that it might be the SSL failure.

Share:
30,773
alias51
Author by

alias51

Updated on July 09, 2022

Comments

  • alias51
    alias51 almost 2 years

    I am trying to use nodejs and socket.io to deliver a webapp, which use websocket on port 3000.

    I have opened port 3000 on my EC2 instance in my management console by adding the inbound TCP rule to the relevant security group, however I still can't access it via public dns on my browser.

    sudo netstat -tulpn doesn't show it as an open port.

    What am I missing? Is there some service I need to restart or a command line I need to push to get it running?

    Thanks