【问题标题】:NodeJs (Express) wont listen to the IP and host in ubuntuNodeJs (Express) 不会在 ubuntu 中监听 IP 和主机
【发布时间】:2016-05-17 19:36:36
【问题描述】:

我已将我的应用部署到 ununtu。

这是垃圾箱/www:

app.set('port', 3000);
app.set('host','app.site.com');
var server = http.createServer(app);
server.listen(port,'64.143.255.122');//I put here a fake IP (deployed with the real one)
server.on('error', onError);
server.on('listening', onListening);

我在我的 PC 中创建了一个主机:64.143.255.122 app.site.com,然后我打开浏览器:http://app.site.com:3000,但它不起作用。

但是,如果我通过lynx,在服务器内部写入lynx http://localhost:3000,它会起作用,我会得到正确的页面。

可能是什么问题?

谢谢

【问题讨论】:

  • 您是否尝试在不指定 ip 的情况下侦听端口?以便它在本地主机上侦听?并在 sever.listen 线上使用 3000 而不是端口?只是为了调试?
  • @rmjoia - 是的,一模一样
  • 它会抛出任何错误吗?在您的错误事件处理程序上?你可能确实找到了这个,但是......我认为帖子提到了端口绑定和所有,stackoverflow.com/questions/18008620/…
  • nslookup app.site.com 显示的 IP 地址是什么?

标签: node.js express


【解决方案1】:

你是否让 iptables 允许它?

试试这个:

iptables -A INPUT -p tcp --dport 3000 -j ACCEPT

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    • 2012-04-05
    • 2017-03-03
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    • 2014-03-16
    相关资源
    最近更新 更多