Skip to content

Port conflict #9133

@cdtut

Description

@cdtut

Astro Info

Node                     v20.8.0
System                   Linux (x64)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Start astro dev and it start on 4321. Start astro dev again and it start on next available port 4322.

Run astro preview and there is error EADDRINUSE: address already in use ::1:4321.

Run node dist/server/entry.mjs and it say [@astrojs/node] Server listening on http://127.0.0.1:4321 even though process already running on 4321.

What's the expected result?

  1. astro preview should open on next available port 4322.
  2. node dist/server/entry.mjs should have error EADDRINUSE: address already in use ::1:4321.
  3. astro preview should have command line option --port and astro config file option to change port to try first.
  4. node adapter should have host and port options that are used as default if environment variable not given. Not every build process can provide environment variables (https://docs.astro.build/en/guides/integrations-guide/node/#runtime-environment-variables).
adapter: node({
    host: "0.0.0.0",
    port: "4321"
})

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-1o5lsw

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions