Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task
eni23 opened this issue Dec 3, 2024 · 2 comments
Closed
1 task

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

eni23 opened this issue Dec 3, 2024 · 2 comments

Comments

@eni23
Copy link

eni23 commented Dec 3, 2024

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

@alan-agius4
Copy link
Collaborator

This issue is not related to Angular. In Node.js 18, the preference for IPv4 over IPv6 has been removed. Instead, Node.js now respects the order returned by DNS entries. As a result, it is no longer guaranteed that "localhost" will resolve to 127.0.0.1. For more details, see: nodejs/node#39987

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants