Skip to content

ng serve --allowed-hosts results in ERR_CONNECTION_REFUSED #25194

Closed as not planned
@MrAlexBailey

Description

@MrAlexBailey

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

Node v16

Description

Running ng serve with an allowed-hosts setting will not connect with Node v18 on Windows.

Minimal Reproduction

Angular setup:

ng new testapp
cd testapp
ng serve --port 80 --allowed-hosts testing.local.dev.com

Windows HOSTS:

# Windows/system32/drivers/etc/HOSTS


127.0.0.1 testing.local.dev.com

Exception or Error

With Node v16.20.0 the example serves normally in a browser @ `testing.local.dev.com`

With Node v18.16.0 the example errors in a browser with `ERR_CONNECTION_REFUSED`

These are both using NG 16.0.1

Your Environment

> testapp@0.0.0 ng
> ng version


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


Angular CLI: 16.0.1
Node: 18.16.0
Package Manager: npm 9.5.1
OS: win32 x64

Angular: 16.0.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.1
@angular-devkit/build-angular   16.0.1
@angular-devkit/core            16.0.1
@angular-devkit/schematics      16.0.1
@schematics/angular             16.0.1
rxjs                            7.8.1
typescript                      5.0.4

Anything else relevant?

Not sure if this issue is node, webpack, or angular related, so if it belongs somewhere more appropriate, any help getting it there would be appreciated.

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