4
votes

I am facing the below issue in angular 4(after starting the server by using ng serve). I am trying to hit the URL i.e http://localhost:4200/ but I am getting the web page showing message as "This site can't be reached ".

Below are nodejs .npm and angular versions.

    PS E:\MyLearning\Angular4Examples\firstapp> node -v
    v8.11.1
    PS E:\MyLearning\Angular4Examples\firstapp> npm -v
    5.6.0
    PS E:\MyLearning\Angular4Examples\firstapp> ng -v

        _                      _                 ____ _     ___
       / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
      / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
     / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
    /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                   |___/

    Angular CLI: 1.7.3
    Node: 8.11.1
    OS: win32 x64
    Angular: 5.2.9
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router

    @angular/cli: 1.7.3
    @angular-devkit/build-optimizer: 0.3.2
    @angular-devkit/core: 0.3.2
    @angular-devkit/schematics: 0.3.2
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.2
    @schematics/angular: 0.3.2
    @schematics/package-update: 0.3.2
    typescript: 2.5.3
    webpack: 3.11.0
    PS E:\MyLearning\Angular4Examples\firstapp>

Server starting steps:

    PS E:\MyLearning\Angular4Examples\firstapp> ng serve
    ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
    Date: 2018-04-01T18:32:35.599Z
    Hash: 2879e8bca9cd899f9051
    Time: 12422ms
    chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
    chunk {main} main.bundle.js (main) 18 kB [initial] [rendered]
    chunk {polyfills} polyfills.bundle.js (polyfills) 554 kB [initial] [rendered]
    chunk {styles} styles.bundle.js (styles) 41.5 kB [initial] [rendered]
    chunk {vendor} vendor.bundle.js (vendor) 7.42 MB [initial] [rendered]

    webpack: Compiled successfully.
3
Have you tried ng serve -o ? That way cli opens the browser with the correct url for youtomichel
I tried above given command ,browser window is opened but My issue is after opening the browser angular home page is not showing .Satheesh
@Satheesh, did you end up with this issue? Got the same. But with 6th version of Angular.Ryan
I am also facing same issue. Please can anyone help.Jay Momaya
Even i am also facing same issue can anyone help me out??Hemanth

3 Answers

0
votes

http://127.0.0.1:4200/ is working?

If yes, you need to edit your hosts file and add the following entry: 127.0.0.1 localhost

0
votes

I also encountered this error after my vs code was auto updated in ubuntu. I ran sudo apt-get update and restarted my computer. Everything worked fine for me.

-1
votes

I fixed my problem by forcing a hard refresh.

Ensure your address bar is using the http. Chrome was redirecting me to HTTPS.

  • Open the Developer Tools panel (CTRL+SHIFT+I)
  • Right-click the reload icon.
  • Choose "Empty Cache and Hard Reload"