Skip to content

fix: pass host to server.listen in serve command#12127

Open
srpatcha wants to merge 1 commit into
facebook:mainfrom
srpatcha:fix/serve-host-binding
Open

fix: pass host to server.listen in serve command#12127
srpatcha wants to merge 1 commit into
facebook:mainfrom
srpatcha:fix/serve-host-binding

Conversation

@srpatcha

@srpatcha srpatcha commented Jun 9, 2026

Copy link
Copy Markdown

Description

server.listen(port) in the serve command ignored the --host CLI flag, always binding to 0.0.0.0 and potentially exposing the dev server to the network.

Changes

  • Pass host parameter to server.listen(port, host)
  • Added EADDRINUSE error handler for better DX when the port is already in use

Testing

  • Verified docusaurus serve --host 127.0.0.1 now correctly binds to localhost only
  • Verified EADDRINUSE error is caught and logged cleanly

Replaces #11965 (closed due to unrelated commits causing Netlify deploy failures).

server.listen(port) ignored the --host flag, always binding to
0.0.0.0 and exposing the dev server on the network. Added host
parameter to server.listen() call and added EADDRINUSE error handler.
@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jun 9, 2026
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 4a2fd85
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a27938da3c8a70008ec457d
😎 Deploy Preview https://deploy-preview-12127--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant