6

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

  1. Updated node.js/ reinstalled node.js
  2. create new app using npx create-react-app but still localhost:3000 isn'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

6
  • Kindly share the error returned. Commented Apr 4, 2020 at 16:30
  • No error. When i run it, my browser says localhost took too long to respond. ERR_CONNECTION_TIMED_OUT Commented Apr 4, 2020 at 16:35
  • Are you sure you have valid proxy settings. Maybe you are running server side not client side? Commented Apr 4, 2020 at 16:37
  • Am sure. Even if i create a new empty app using npx create-react-app, it is the same. Both server and client run without error but not accessible. Commented Apr 4, 2020 at 16:48
  • That error implies that your server and client aren't communicating. This might have to do more with the resources on your machine. If machine is running other intensive processes, you might need to stop them first. Commented Apr 4, 2020 at 16:58

4 Answers 4

3

create .env file at the root of your project and add this line:

PORT = 3000

Then npm start again

Sign up to request clarification or add additional context in comments.

Comments

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"

Comments

1

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.

1 Comment

Thank you, this was my issue, because of some vulnerability scanner I put this line in my package.json overrides: "http-proxy-middleware": ">=2.0.7". npm went ahead and installed version 3.0.3, I changed it to 2.0.7 exact and it fixed my issue. I'm using CRA with react 17. React-scripts has nothing to do with this, I'm using craco.
0

Try Updating your react-scripts version if you use create-react-app

The error also occurs if you have an outdated version of react-scripts in your create-react-app project.

if you use npm

npm install react-scripts@latest

if you use yarn

yarn add react-scripts@latest

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.