How do I run a Next.js application on a different port number?

nick asked this question 5 months ago
nick on Dec 3, 2021

By default, Next.js runs on the localhost:3000 port.

How do I change that to use a different port, like 8080, 5000, etc.

1 suggested answers
coderguy on Dec 8, 2021 · Edited

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.

0 replies