NodeJs Application on Aws Ubuntu is running on ipv

2019-09-10 02:06发布

While running nodejs with express application on AWS ubuntu 16.04, it's running on tcp6 and due to this, i'm unable to access my application. see below screenshot. enter image description here

after adding IP address while creating server, it's giving below error. enter image description here

I'm new to linux, so I do not know how to resolve it. please suggest.

1条回答
成全新的幸福
2楼-- · 2019-09-10 02:51

You need to explicitly provide an IP to bind to in Node.js, otherwise it binds to IPv6. Documented here: https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_server_listen_port_hostname_backlog_callback

Somewhere in your code you should have something similar to this:

var app = express();
app.listen(1234);

Change it to:

var app = express();
app.listen(1234, '127.0.0.1');
查看更多
登录 后发表回答