Answered
By default, Next.js runs on the localhost:3000
port.
How do I change that to use a different port, like 8080
, 5000
, etc.
Open the package.json
file for your application and update the "scripts"
section to this:
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "next start -p 8080"
},
This will tell Next.js to run the application on port 8080
in both development mode and production mode.
Change 8080
to whatever port number you want to use instead.