AWS上的NodeJs应用程序Ubuntu在ipv6上运行 [英] NodeJs Application on Aws Ubuntu is running on ipv6

查看:130
本文介绍了AWS上的NodeJs应用程序Ubuntu在ipv6上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然在AWS ubuntu 16.04上运行带有快速应用程序的nodejs,但它在tcp6上运行,因此,我无法访问我的应用程序. 请参见下面的屏幕截图.

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.

在创建服务器时添加IP地址后,出现以下错误.

after adding IP address while creating server, it's giving below error.

我是Linux的新手,所以我不知道如何解决它.请提出建议.

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

推荐答案

您需要在Node.js中显式提供要绑定的IP,否则它将绑定到IPv6.在此处记录: https://nodejs.org/dist/latest-v6.x/docs/api/http.html#http_server_listen_port_hostname_backlog_callback

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);

将其更改为:

var app = express();
app.listen(1234, '127.0.0.1');

这篇关于AWS上的NodeJs应用程序Ubuntu在ipv6上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆