server.port
- Type:
number - Default:
3000
Sets the port number for the Rsbuild server.
By default, the Rsbuild server listens on port 3000 and automatically increments the port when it's occupied. Enable server.strictPort to throw an error instead of incrementing the port when it's occupied.
The Rsbuild CLI provides a --port option to set the port number. The --port option takes priority over the server.port config.
Example
Set the port to 8080:
rsbuild.config.ts
Set different port numbers for development and preview servers:
rsbuild.config.ts
Dynamic port
Set server.port to 0 to let the operating system assign an available port:
rsbuild.config.ts
This is particularly useful in test scenarios, as it avoids port conflicts when multiple tests start Rsbuild servers simultaneously.

