0

I am not able to run many project in 3000 port at the same time.

How can I change react port for run multiple react project at the same time. Any solution for this problem?

Show this message: Something is already running on port 3000.

  • 4
    Does this answer your question? [How to specify a port to run a create-react-app based project?](https://stackoverflow.com/questions/40714583/how-to-specify-a-port-to-run-a-create-react-app-based-project) – Andy Ray May 24 '23 at 05:44
  • Even easier than the link above suggest would be just: `PORT=3006 npm start` instead of `npm start` – RAllen May 24 '23 at 05:56

2 Answers2

1

Try changing the "scripts" section in your package.json, in the "start" also set the environment variable PORT with a value different than 3000:

...
"scripts": {
    "start": "set PORT=3500 && react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
...
0

If React app created with Vite, add port to server block in vite.config.js.

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],

  server: {
    // change to desired port
    port: 3000
  }
})
Arty.Simon
  • 844
  • 2
  • 7
  • 21