不能连接快递应用程序

本地我可以连接到我的快速应用程序在端口9000.如果我在远程服务器上启动它,我没有成功达到应用程序,但我看到在控制台日志中,它成功启动。

$my-express-app pm2 start bin/www之后,我看到netstat命令的下一个输出

 tcp6 0 0 :::3000 :::* LISTEN 52407/www tcp6 0 0 :::8000 :::* LISTEN 43298/server.js tcp6 0 0 :::9000 :::* LISTEN 52407/www 

接下来,如果我以$my-express-app pm2 start app.js

 tcp6 0 0 :::8000 :::* LISTEN 43298/server.js tcp6 0 0 :::9000 :::* LISTEN 53096/app.js 

接下来我的设置configuration

  ................... app.set('port', 9000) ................... app.listen(app.get('port')); 

我错过了什么吗?

Express版本是4.x

更新

我也尝试绑定应用程序来听任何ip app.listen(app.get('port'),'0.0.0.0')

我添加了2个input/输出规则(之前存在udp规则)

 Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:9000 ACCEPT udp -- anywhere anywhere udp dpt:bootpc Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere 

ufw status告诉我它不活动。

没有成功。 环境Ubuntu 14.04

更新

我能够运行应用程序的端口8000,其他js应用程序正常运行。 我无法find任何有关此端口的设置。 9000仍然没有工作。 下面是9000端口的nmap扫描

 nmap -p 9000 127.0.0.1 Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-04 08:52 UTC Nmap scan report for localhost (127.0.0.1) Host is up (0.000070s latency). PORT STATE SERVICE 9000/tcp open cslistener Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds nmap -p 9000 myip Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-04 08:52 UTC Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn Nmap done: 1 IP address (0 hosts up) scanned in 3.05 seconds 

解决

我需要在Azure门户上将端点设置为端口9000。 它现在有效。 谢谢。

您应该检查您的远程服务器防火墙,并添加要打开通信的端口9000。

你正在使用什么操作系统,谁在为你托pipe这个服务器? 例如,我知道如果你在DigitalOcean上租用Ubuntu服务器,大多数端口(包括9000)将被防火墙ufw默认阻塞。 如果您运行的是Ubuntu的新版本,则可以使用ufw status来检查当前的防火墙规则。 您可能需要修改您的防火墙规则ufw allow 9000