Phi*_* YS 0 linux ubuntu amazon-ec2 amazon-web-services node.js
这是app.js,代码太长,所以我只显示这段代码,其他代码没有问题,我认为这是网络问题。
应用程序.js
app.listen(8080, 'localhost', function () {
console.log('Express started on http://localhost:' + 8080 + '; press Ctrl-C to terminate.');
});
Run Code Online (Sandbox Code Playgroud)
我跑的时候没有任何反应lsof -i :8080。但是当我跑步时我确实得到了回应curl localhost:8080在服务器上。
而且我认为安全组没有任何问题。我允许任何 ip 访问实例,如下所示。
这里实际上它看起来像当我测试public ip和localhost
ubuntu@:ip~/$ curl -v 18.217.107.76:8080
* Rebuilt URL to: 18.217.107.76:8080/
* Trying 18.217.107.76...
* connect to 18.217.107.76 port 8080 failed: Connection refused
* Failed to connect to 18.217.107.76 port 8080: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 18.217.107.76 port 8080: Connection refused
ubuntu@ip:~/$ curl -v localhost:8080
I get response here!
Run Code Online (Sandbox Code Playgroud)
我改变了代码
app.listen(8080, 'localhost', function () {
console.log('Express started on http://localhost:' + 8080 + '; press Ctrl-C to terminate.');
});
Run Code Online (Sandbox Code Playgroud)
到
app.listen(8080, function () {
console.log('Express started on http://localhost:' + 8080 + '; press Ctrl-C to terminate.');
});
Run Code Online (Sandbox Code Playgroud)
现在它正在工作
| 归档时间: |
|
| 查看次数: |
2606 次 |
| 最近记录: |