By default, localhost:3000 is the default port when you create a React project. However, to avoid port conflicts, changing the port is necessary, and this article will guide you on how to do it.
First, edit the package.json file. In the “start” script, add “set PORT=3050 && react-scripts start.”
//package.json "scripts": { "start": "set PORT=3050 && react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }
for Linux and MacOS to:
"start": "PORT=3006 react-scripts start"
Next, create a .env file with PORT=3050 (or any preferred port).
//.env PORT=3050
Run npm start and check the results!