Skip to content

ng serve per default only listens on IPv6 (Linux) #29028

@eni23

Description

@eni23

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

ng serve seems to only listen on IPv6 per default.

This seems like pretty weird behaviour, as most services do not work like that, and it makes debugging issues which involves networks and proxies kind of unexcepted.

Minimal Reproduction

Serve an application:

ng serve

[..]
Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because lockfile has changed
  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help

It says its listening on localhost.
Localhost is resolving to both ::1 and 127.0.0.1. Still ng decides to only listen on ::1:

netstat -pnlt | grep ':4200'
tcp6       0      0 ::1:4200                :::*                    LISTEN      2145414/ng serve

I can force it to run it on IPv4 with binding to 127.0.0.1 or 0.0.0.0, but then it only listens to ipv4, and not 6 of course:

ng serve --host 127.0.0.1

netstat -pnlt | grep ':4200'
tcp        0      0 127.0.0.1:4200          0.0.0.0:*               LISTEN      2152537/ng serve --

Starting it explicitly with localhost also only binds it to IPv6:

ng serve --host localhost

netstat -pnlt | grep ':4200'
tcp6       0      0 ::1:4200                :::*                    LISTEN      2164254/ng serve --

It seems like this "issue" is only reproducible on Linux, on Mac OSX, ng binds "correctly".

Exception or Error


Your Environment

Angular CLI: 17.3.2
Node: 20.9.0
Package Manager: npm 10.1.0
OS: linux x64

Angular: 17.3.12
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                              Version
--------------------------------------------------------------
@angular-devkit/architect            0.1703.2
@angular-devkit/build-angular        17.3.2
@angular-devkit/core                 17.3.2
@angular-devkit/schematics           17.3.2
@angular/cdk                         17.3.10
@angular/cli                         17.3.2
@angular/material                    17.3.10
@angular/material-date-fns-adapter   17.3.10
@schematics/angular                  17.3.2
rxjs                                 7.8.1
typescript                           5.4.3
zone.js                              0.14.4

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions