75009

NodeJs Application on Aws Ubuntu is running on ipv6

Question:

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. <a href="https://i.stack.imgur.com/SoJTH.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/SoJTH.png" data-original="https://i.stack.imgur.com/SoJTH.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

after adding IP address while creating server, it's giving below error. <a href="https://i.stack.imgur.com/4vbX1.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/4vbX1.png" data-original="https://i.stack.imgur.com/4vbX1.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

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

Answer1:

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

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

Recommend

  • Google OAuth2 for an web application hosted behind NAT (intranet server without public IP)
  • How to resolve docker host names (/etc/hosts) in containers
  • Should I be afraid to use UDP to make a client/server broadcast talk?
  • R sqldf renaming a field in a select statement
  • Available space left on drive - WinAPI - Windows CE
  • In C what exactly happens if i use () to initialize a double dimension array instead of the {}?
  • Symfony 2 error page response
  • Which open source license has no forking [closed]
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • Redshift Querying: error xx000 disk full redshift
  • Thread 1: EXC_BAD_ACCESS (code =1 address = 0x0)
  • SAXReader not re-ecape characters
  • How do I include a SWC in an AS2 Flash project?
  • How to add a focus style to an editable ComboBox in WPF
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • How do I superscript characters in a UIButton?
  • How can I set a binding to a Combox in a UserControl?
  • Zurb Foundation _global.scss meta styles for js?
  • Rails Find when some params will be blank
  • Meteor: Do Something On Email Verification Confirmation
  • Cannot resolve symbol 'MyApi'
  • Initializer list vs. initialization method
  • Control modification in presentation layer
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Deselecting radio buttons while keeping the View Model in synch
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Fetching methods from BroadcastReceiver to update UI
  • Resize panoramic image to fixed size
  • Volusion's generic SQL folder, functionality
  • Join two tables and save into third-sql
  • How to make Safari send if-modified-since header?
  • How can I estimate amount of memory left with calling System.gc()?
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass