server.port

  • Type: number
  • Default: 3000

Specify a port number for Rsbuild Server to listen.

By default, Rsbuild Server listens on port 3000 and automatically increments the port number when the port is occupied. If you enable the server.strictPort config, Rsbuild Server will throw an error instead of incrementing the port number when the port is occupied.

Rsbuild CLI provides the --port option to set the port number, and the --port option has higher priority than 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,
  },
};
ON THIS PAGE