Skip to content

fix: allow run-windows to start Metro on custom port - #16126

Merged
acoates-ms merged 1 commit into
microsoft:mainfrom
vivekjm:fix-run-windows-packager-port
May 12, 2026
Merged

acoates-ms merged 1 commit into
microsoft:mainfrom
vivekjm:fix-run-windows-packager-port

Conversation

@vivekjm

@vivekjm Vivek JM (vivekjm) commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

run-windows already accepts the rest of the usual packager flow, but the Metro status check and startup command were still pinned to 8081. That makes --no-packager the only practical path when another tool owns the default port.

This adds the same kind of --port override that React Native developers already expect from the CLI, so run-windows --port 9000 checks and starts Metro on that port.

Resolves #6833

What

  • Added a --port option to run-windows, defaulting to 8081.
  • Reused the port parser for --direct-debugging and kept the valid user port range consistent.
  • Used the configured port for the Metro /status probe and for the start --port command.
  • Added coverage for the new option in the existing run-windows option test.

Screenshots

Not applicable; this is CLI behavior.

Testing

Ran locally:

corepack yarn workspace @react-native-windows/cli exec jest --config jest.config.js --testRegex 'src/e2etest/runWindows.test.ts' --runInBand
corepack yarn workspace @react-native-windows/cli exec prettier --check src/commands/runWindows/runWindowsOptions.ts src/utils/deploy.ts src/e2etest/runWindows.test.ts
corepack yarn workspace @react-native-windows/cli exec tsc --noEmit --project tsconfig.json

Changelog

Should this change be included in the release notes: yes

Allow run-windows --port to start and check Metro on a non-default port.

Microsoft Reviewers: Open in CodeFlow
@vivekjm

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@vivekjm
Vivek JM (vivekjm) force-pushed the fix-run-windows-packager-port branch from 216f7eb to 5d251d2 Compare May 12, 2026 20:03
@acoates-ms

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).
@vivekjm
Vivek JM (vivekjm) force-pushed the fix-run-windows-packager-port branch from 5d251d2 to 9b28ddf Compare May 12, 2026 20:14
@azure-pipelines

Copy link
Copy Markdown
Contributor
Commenter does not have sufficient privileges for PR 16126 in repo microsoft/react-native-windows
@acoates-ms

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).
@acoates-ms
acoates-ms merged commit cec070e into microsoft:main May 12, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants