skip to Main Content

I have simple angular app and updated port in angular.json with my port as,

  "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ceams-ui:build",
            "port": 4444
          },
$ ng --version

     _                      _                 ____ _     ___
    /    _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / Γû│  | '_  / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ | | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   __| |_|__, |__,_|_|__,_|_|       ____|_____|___|
                |___/


Angular CLI: 10.2.0
Node: 12.19.0
OS: win32 x64

Angular: 10.1.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1002.0
@angular-devkit/build-angular   0.1002.0
@angular-devkit/core            10.2.0
@angular-devkit/schematics      10.2.0
@angular/cdk                    10.2.7
@angular/cli                    10.2.0
@angular/flex-layout            10.0.0-beta.32
@angular/material               10.2.7
@schematics/angular             10.2.0
@schematics/update              0.1002.0
rxjs                            6.6.3
typescript                      4.0.5

$ ng serve succeeds as
Date: 2021-03-01T17:18:10.880Z – Hash: 8144cdb2f65873b9a965 – Time: 31537ms
** Angular Live Development Server is listening on localhost:4444, open your browser on http://localhost:4444/ **
: Compiled successfully.

On LOCAL browser, it always Errors Out as,
This site can’t be reached.

Whereas my "curl http://localhost:4444/" succeeds.
It works perfectly with default port 4200. Not sure what is going on
Observation: The netstat -tln output,
Tried but No luck. One observation the "netstat -tln" gives local IP as "127.0.0.1" but for 4200 it is different,

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:4200            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:4444          0.0.0.0:*               LISTEN

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution with reference of https://github.com/angular/angular-cli/issues/2375 The 'ng' by default sets n/w interface with 127.0.0.0 , we need to explicitly mention on command with "--host 0.0.0.0" thats all :-)

    So the actual command should be,

    ng serve --host 0.0.0.0 --port 4444
    

  2. Change the port via command and then try:

    ng config projects.(your-project-name).architect.serve.options.port (port-no)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search