Change NextJS default port

January 13, 2021
views 1 min read

While writing my last article I was running my blog on port 3000, and since I test all of my articles with actually building it myself, I came across needing to run the projects on another port.

Changing the port

I've decided I would start running my blog on port 3002. It's as simple as opening package.json file and changing the dev script:

"scripts": {
- "dev": "next",
+ "dev": "next -p 3002",
  "build": "next build",
  "start": "next start"

Now when you run npm run dev it'll start your project on port 3002, or whatever number you've chosen.

That's it.

Read next
Getting started with Next.js and Prisma
October 16, 2021