For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /configure/app/server/port.md.

server.port

  • Type: number
  • Default: 8080

When running the dev and serve commands, Modern.js will start with 8080 as the default port and automatically increase the port number when the port is occupied. You can use this configuration to modify the port number that the Server starts with:

modern.config.ts
export default defineConfig({
  server: {
    port: 3000,
  },
});
Info

The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to Rsbuild - server.port.