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.

npx rsbuild dev --port 8080

Example

Set the port to 8080:

export default {
  server: {
    port: 8080,
  },
};

Set different port numbers for development and preview servers:

export default {
  server: {
    port: process.env.NODE_ENV === 'development' ? 3000 : 8080,
  },
};