HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptreactCritical

How to Set port in next.js

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
nexthowportset

Problem

One application is running on port 3000 and I want to run another application on a different port from the default port, which is 3000. How do I change this in React Next.js? My package.json currently contains:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "next",
    "build": "next build",
    "start": "next start"
},


And the CLI command that I use to start dev is npm run dev.

Solution

This work for me:

"scripts": { 
    "dev": "next dev -p 8080",
    "start": "next start -p 8080",
},

Code Snippets

"scripts": { 
    "dev": "next dev -p 8080",
    "start": "next start -p 8080",
},

Context

Stack Overflow Q#60147499, score: 613

Revisions (0)

No revisions yet.