Angular-cli: ng serve - doesn't listen on all interfaces by default

Created on 21 Sep 2016  路  6Comments  路  Source: angular/angular-cli

ng help lists Listens on all interfaces by default under the ng serve section. However, in fact the server listens on 127.0.0.1 only.

Please, set the node.js to 0.0.0.0 or change the message.

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    Win8.1
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.15 node: 6.6.0 os: win32 x64
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
    ng init; ng serve
  4. The log given by the failure. Normally this include a stack trace and some
    more information.
  5. Mention any other details that might be useful.

Most helpful comment

Nvm. Works with command ng serve --host 0.0.0.0

All 6 comments

Please, set the node.js to 0.0.0.0 or change the message.

Do you know how to do that? I am facing the same issue.

Nvm. Works with command ng serve --host 0.0.0.0

Hello!

I've launched ng serve using the command above, but when I'm trying to access the server through public IP address, I'm getting the error: Invalid Host header. How do I overcome this? How do I make it accept any host header?

Thank you!

The full command should look like this: $ ng serve --port 8080 --host 0.0.0.0 --disable-host-check, the --disable-host-check option will allow to use any host header. The following thread, could also be useful: https://github.com/angular/angular-cli/issues/6349.

ng serve --port 8080 --host 0.0.0.0

This solution works fine

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings