Unable to access node express application from firewall

I am new to networking and assigning ports and things of this nature. I have been using a stroller for some time and have never experienced any problems trying to get a test environment and then access it through the host machine’s browser. The setup for this in my Vagrantfile is this:

# network stuff
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "test-box-debian"

Now I'm trying to learn a little about node.js, and each tutorial says that I can run npm start, and it works great. I can call wget localhost:3000(port 3000 is used in the expression by default) and get the index.htmldefault page from the expression in return .

However, when I try to access "192.168.33.10haps000" from the host browser, it does not work. I can run netstat and get the following as a result:

sudo netstat -ltpn | grep 3000
tcp6       0      0 :::3000                 :::*                         LISTEN      17238/node  

I see that something does not look right, but I just don’t know enough about ports and the network to find out what is wrong and how to fix it.

+4
source share
2 answers

First, make sure your server is listening on the correct IP address and that you have not tied the Express listener elsewhere:

.listen(3000), NOT .listen(3000, '127.0.0.1')

Alternatively, try associating the Express server with your private IP address or with a wildcard IP address and see if this fixes your connection problems:

// Wildcard (All IP's) binding
  .listen(3000, '0.0.0.0')

// Specific binding
  .listen(3000, '192.168.33.10')

, 3000 . , Vagrantfile:

config.vm.network "forwarded_port", guest: 3000, host: 3000

+4

, , :

sudo iptables -I INPUT -p tcp --dport 3000 -j ACCEPT

fooobar.com/questions/1598989/....

+3

Source: https://habr.com/ru/post/1598987/


All Articles