Angular 6 ERR_CONNECTION_TIMED_OUT

angular

#1

Hi evryone.
I’m trying to use angular 6. when I hit:
ng serve --open

everything seem to work fine and i get:

Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/

Date: 2018-07-01T10:56:41.798Z
Hash: e8e3505bb172de5054c9
Time: 12051ms
chunk {main} main.js, main.js.map (main) 10.7 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.07 MB [initial] [rendered]
:information_source: 「wdm」: Compiled successfully.

But when I get into : localhost:4200 I get ERR_CONNECTION_TIMED_OUT
Does anyone have any idea what the problem might be? Thanks.


#2

C9 does not listen on port 4200. For Angular’s server, only ports 8080 & 8081 are available. I’ve always used the following steps for setting up Angular v.4+ & 5+ on C9. Hopefully these still work for v.6+:

C9/Angular setup:

  1. $ nvm install node (installs latest node version within C9 workspace environment)
  2. $ nvm ls (see what version was installed, use that version in next command)
  3. $ nvm alias default (makes version the workspace default)
  4. $ npm i -g npm (updates npm version to match new node version)
  5. $ npm install -g @angular/cli
  6. $ ng new my-new-ngapp
  7. Change package.json “scripts.start” line to : “start”: “ng serve --host 0.0.0.0 --port 8080 --public $C9_HOSTNAME”,
  8. CD to new application’s directory & start server with “$ npm start” command

–host 0.0.0.0 is how “localhost” is configured for a virtual environment like C9. --port 8080 assigns the Angular server to port 8080, which is one of the available C9 ports. --public $C9_HOSTNAME provides the necessary security config for Angular’s server (Google the --public flag for more info)


#3

AlohaCode Thank you very much!
I gott :
Unknown option: ‘–public’
so i changed it to:
ng serve --host 0.0.0.0 --port 8080 --disableHostCheck
and this is working now.
Thanks again.