How to change port in Next.js Appstandoski2 years ago

       

How to change port in Next.js App

The default port for next.js applications running locally is 3000. Since it's a frequently utilized port, there may be other services using it as well.

You can set port number using below ways:

1. package.json

In the scripts section of package.json, there will be a command for dev.

which is likely to be "dev": "next dev"

Change the package.json to set the port number. To make the port number 3002 or any other number of your choice, use the contents as shown below.

"dev": "next dev -p 3002"

2. specify port number in run command

While running your application, specify the port number. You can use the command like below:

npm run dev -- -p 3002

5 Comment

    a few seconds ago

    a few seconds ago

    a few seconds ago

    a few seconds ago

    a few seconds ago

Leave A Comment