#standalone
1 messages · Page 1 of 1 (latest)
Hi @haughty cape. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
When using Next.js with standalone output, you can change the default port (3000) by setting environment variables before running the server.js file. According to the documentation, you can define the PORT environment variable to specify a different port:
PORT=8080 node .next/standalone/server.js
If you also need to specify a hostname (for example, to make your app accessible from other devices on your network), you can use the HOSTNAME environment variable:
PORT=8080 HOSTNAME=0.0.0.0 node .next/standalone/server.js
This will start your server on <http://0.0.0.0:8080> instead of the default <http://localhost:3000.>
Next.js Output Configuration specifically mentions this in their documentation:
If your project needs to listen to a specific port or hostname, you can define
PORTorHOSTNAMEenvironment variables before runningserver.js.