angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve doesn't listen other than localhost

Open gyuho opened this issue 10 years ago • 23 comments

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Ubuntu 16.04

  1. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
node --version
v6.6.0
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

I have this app https://github.com/jelbourn/material2-app.

And just type npm start in repository root. Both in remote and local machine, I see

> [email protected] start /home/gyuho/material2-app
> ng serve

Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
** NG Live Development Server is running on http://localhost:4200. **
8221ms building modules                                                                  
23ms sealing
0ms optimizing 
1ms basic module optimization 
97ms module optimization
0ms advanced module optimization 
11ms basic chunk optimization       
0ms chunk optimization 
2ms advanced chunk optimization 
0ms module and chunk tree optimization 
150ms module reviving
2ms module order optimization 
5ms module id optimization 
3ms chunk reviving 
0ms chunk order optimization 
13ms chunk id optimization
83ms hashing
1ms module assets processing 
188ms chunk assets processing
5ms additional chunk assets processing 
0ms recording 
0ms additional asset processing 
2415ms chunk asset optimization
1616ms asset optimization
37ms emitting
Hash: 93c935dc7d6ef86a5d1e
Version: webpack 2.1.0-beta.22
Time: 12902ms
           Asset       Size  Chunks             Chunk Names
  main.bundle.js    3.43 MB    0, 2  [emitted]  main
styles.bundle.js    43.4 kB    1, 2  [emitted]  styles
       inline.js    5.53 kB       2  [emitted]  inline
        main.map     3.5 MB    0, 2  [emitted]  main
      styles.map    53.8 kB    1, 2  [emitted]  styles
      inline.map    5.59 kB       2  [emitted]  inline
      index.html  580 bytes          [emitted]  
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.92 kB       0       
webpack: bundle is now VALID.

But when I try to connect to http://[PUBLIC_IP_ADDRESS_OF_CLOUD]:4200, it doesn't serve. I checked all network settings (I am using Google Cloud VM) and confirm that there's no firewall blocking :4200.

Same simple webserver in Go listening to :4200 works fine on the same machine.

Is there anything that I am missing to deploy angular app in virtual machines?

gyuho avatar Sep 27 '16 19:09 gyuho

@ludwigliu , @lgoyal06 , @rohit2219 , Can anyone of you please explain how you fix it? I try modification in the .angular-cli.json: "serve": { "host": "0.0.0.0", "port": 4201 } and running ng serve --host 0.0.0.0 The angular app is not loading. I have another api url which is loading though. It is weird. Please help me.

vanishtachangea avatar Feb 28 '19 09:02 vanishtachangea

@levivel You solved my problem thanks, how can I fix it permanently without changing host/port. Im using different cloud service, but I assume it can apply to my service. one more question, what you mean you "without enabling production"?

hamed6 avatar May 03 '19 08:05 hamed6

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.