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:
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"
While running your application, specify the port number. You can use the command like below:
npm run dev -- -p 3002