Skip to content

Angular 17: getting Internal server error: Invalid URL error when starting dev server #27327

@harshpatel147

Description

@harshpatel147

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

Description

today I installed the angular 17 with SSR. after installation when I run ng serve --project my-app --host x.x.x.x --port 4200 for start dev server. dev server starting on given host port. but when I open url in browser then I'm getting following error.

1:03:41 PM [vite] Internal server error: Invalid URL
      at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:164:36
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:203:47

If I start dev server on localhost ng serve --project my-app & run url in browser then work charm. this above issue face only when starting the dev server on IP

you can see below full console log of dev server

ng serve --project my-app --host x.x.x.x --port 4200

Warning: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disable-host-check" if that's the
case.
    
Browser bundles        
Initial chunk files     | Names               |  Raw size
polyfills.js            | polyfills           |  83.60 kB | 
main.js                 | main                |  22.22 kB | 
styles.css              | styles              | 118 bytes | 

                        | Initial total       | 105.93 kB


Server bundles         
Initial chunk files     | Names               |  Raw size
chunk-V6QZVQ3I.mjs      | -                   |   1.70 MB | 
polyfills.server.mjs    | polyfills.server    | 555.05 kB | 
main.server.mjs         | main.server         | 215.13 kB | 
chunk-VPSODEBW.mjs      | -                   |   2.51 kB | 
render-utils.server.mjs | render-utils.server | 423 bytes | 

Lazy chunk files        | Names               |  Raw size
chunk-OTT6LQ5K.mjs      | xhr2                |  39.10 kB | 

Application bundle generation complete. [4.464 seconds]

Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because lockfile has changed
  ➜  Network: http://x.x.x.x:4200/
  ➜  press h + enter to show help
1:03:41 PM [vite] Internal server error: Invalid URL
      at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:164:36
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:203:47

Minimal Reproduction

ng generate application ordering-app
? Would you like to share pseudonymous usage data about this project with the Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
details and how to change this setting, see https://angular.io/analytics. No
Global setting: enabled
Local setting: disabled
Effective status: disabled
? Which stylesheet format would you like to use? Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? Yes

Exception or Error

No response

Your Environment

ng v

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

Angular CLI: 17.3.1
Node: 18.19.1
Package Manager: npm 10.2.4
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1703.1 (cli-only)
@angular-devkit/core         17.3.1 (cli-only)
@angular-devkit/schematics   17.3.1 (cli-only)
@schematics/angular          17.3.1 (cli-only)

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions