'React js isn't running my app on localhost:3000
hi all i used to work on MERN project for sometime but now my react app wont run on localhost:3000. So far i tried the following
- Updated
node.js/ reinstalled node.js - create new app using
npx create-react-appbut stilllocalhost:3000isn't working
I checked if port is opened or not using netstat -aon but localhost:3000 wasn't there. But 0.0.0.0:3000 is there. So my attempt to run telnet 127.0.0.1 3000 was not successful.
Am using windows 10 OS and latest version of nodejs
Solution 1:[1]
create .env file at the root of your project and add this line:
PORT = 3000
Then npm start again
Solution 2:[2]
Try the solution from this topic.
In package.json edit next string from this
"start": "react-scripts start"
to this
"start": "set PORT=3000 && react-scripts start"
Solution 3:[3]
Finally i found the solution i did installed a package htt-proxy-middleware which actually bugged some files in react, still not sure.
but simply you can get back to work by deleting your package-lock.json and entering
npm i
to reinstall all the packages. It worked for me. I hope it will solve the problem for other developers too.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | carrany |
| Solution 2 | aopanasenko |
| Solution 3 | Wasal Rasool |
