请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

node app.js启动问题

老师:我ip使用127.0.0.1服务能启动,访问超时报错。如果我把ip改为我的外网ip,那么执行起来就报错,急求指点,谢谢?

https://img1.sycdn.imooc.com//szimg/5b3b4ccd0001307907960712.jpg

//img1.sycdn.imooc.com//szimg/5b3af48900011a7109140396.jpg

//img1.sycdn.imooc.com//szimg/5b3af4890001502010920980.jpg

//img1.sycdn.imooc.com//szimg/5b3af48c0001dc9b09920462.jpg


正在回答 回答被采纳积分+3

3回答

Scott 2018-07-04 20:21:46

你服务开起来后,可以现在服务器上命令行操作

curl http://127.0.0.1:8080


看能不能返回数据,如果这个都不能,说明服务就没起来

0 回复 有任何疑惑可以回复我~
  • 提问者 woniu2015 #1
    curl http://127.0.0.1:8080返回是的html哦,是nginx的初始页面,这样服务是跑起来了吗
    执行node app.js
    返回
    Confiugre: host=127.0.0.1, port=8080
    Server created: [object Object]
    执行:curl http://127.0.0.1/
    返回
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
            width: 35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    回复 有任何疑惑可以回复我~ 2018-07-05 19:56:57
Scott 2018-07-04 20:20:51

把 iptables 先关闭了,试试看


我是看到你截图上,node app.js 这个地方有报错,服务没有成功开起来,这个你确定是 ok 的?

0 回复 有任何疑惑可以回复我~
  • 提问者 woniu2015 #1
    curl http://127.0.0.1:8080 返回正常,但网页打不开,显示超时会是怎么回事哦
    回复 有任何疑惑可以回复我~ 2018-07-06 17:09:11
Scott 2018-07-03 19:31:45

应该是你服务器的服务开启失败了,所以外网访问不到


你把端口换一个,比如换成 6677 试试看,不要用 8080

0 回复 有任何疑惑可以回复我~
  • 提问者 woniu2015 #1
    服务器是运行着的,我换了好几个端口都不行哦。然后就是只要我配置了vi /etc/iptables.up.rules 就会无法登陆,实在无解,现在连远程链接都不行了
    回复 有任何疑惑可以回复我~ 2018-07-03 22:07:45
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信