Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localhost:3000 refused to connect #9448

Closed
ariffadhillah opened this issue Aug 7, 2020 · 25 comments
Closed

localhost:3000 refused to connect #9448

ariffadhillah opened this issue Aug 7, 2020 · 25 comments

Comments

@ariffadhillah
Copy link

ariffadhillah commented Aug 7, 2020

I run a yarn start on my application, but can't connect to localhost

I use
windows 10 64bit,
node v14.7.0
npm v6.14.7
and
yarn v1.22.4

but when I run other applications everything runs smoothly

Untitled

@judicaelandria
Copy link

Hey @ariffadhillah ,
can you show us a screenshot of your terminal ?

@ariffadhillah
Copy link
Author

Hey @ariffadhillah ,
can you show us a screenshot of your terminal ?

is there a solution so i can run the npm/yarn start on my application and can connect to localhost

Untitled

@judicaelandria
Copy link

judicaelandria commented Aug 7, 2020

Seems like the problem comes from your start scripts, the react server didn't start
try something like this instead
"scripts": {
"start": "react-scripts start",
"dev": "(yarn run tailwind && yarn run stubby) & yarn run start"
}

@ariffadhillah
Copy link
Author

Thank you so much Judicaelandria,
for his help, now I have successfully connected to localhost

@judicaelandria
Copy link

glad it helped :)

@Namyalg
Copy link

Namyalg commented Jul 3, 2021

I am facing the same issue, the error message is localhost refused to connect

@judicaelandria
Copy link

Hi @Namyalg
care to share a screenshot?

@nebosite
Copy link

nebosite commented Jan 5, 2022

This started happening to me after upgrading to react-scripts 5. I rolled back to 4 and it works now.

@kuzaxak
Copy link

kuzaxak commented Jan 8, 2022

Same for me, nothing in express logs:

Compiled successfully!

You can now view operator-admin in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.88.19:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

assets by path static/ 5.11 MiB
  assets by path static/js/*.js 5.07 MiB
    assets by chunk 1.83 MiB (id hint: vendors) 5 assets
    32 assets
  assets by path static/media/*.svg 39.4 KiB
    assets by chunk 7.38 KiB (auxiliary name: main) 8 assets
asset asset-manifest.json 15.4 KiB [emitted]
asset index.html 1.35 KiB [emitted]
cached modules 4.05 MiB [cached] 765 modules
runtime modules 31.5 KiB 16 modules
./src/index.jsx 2.15 KiB [built] [code generated]
webpack 5.65.0 compiled successfully in 1363 ms

When checking open TCP ports via netstat -anvp tcp | awk 'NR<3 || /LISTEN/' nothing is here. Looks like an error with port opening

@nebosite
Copy link

AWESOME!!! I will check it out soon! THANK YOU!!

@kuzaxak
Copy link

kuzaxak commented Jan 11, 2022

I solved that issue by removing the npm cache, for some reason after cache cleaning dev server works.

@nebosite
Copy link

For me, the issue turned out to be related to having mode code on a file share. When I move the code to the hard disk, it worked.

@Hasib-rafi1
Copy link

Hasib-rafi1 commented Feb 8, 2022

HI guys. this is a proxy issue. if you upgraded the react-script to 5.0.0 Here is the solution.

Solution 1:
try this 2 commands

npm config rm proxy
npm config rm https-proxy

If the above solution does not help you then the next one you have to follow

This appears to be an issue with your proxy settings since when you're running create-react-app <app_name> yarn is unable to resolve the necessary dependencies to set up your new react project, namely: react, react-dom, and react-scripts.

Maybe you could try setting your proxy settings so you can install the necessary libraries create-react-app needs. According to yarn's documentation:

"For backward compatiibilty with npm, Yarn allows passing down npm configuration via environment variables."

So maybe you could try the following and seeing if this helps resolve your issue:

npm config set proxy <proxy_url>
npm config set https-proxy <proxy_url>

where the <proxy_url> is changed to work with your appropriate proxy. Then you can tell yarn to ignore ssl if necessary. Note: Use at your own discretion.

yarn config set strict-ssl false

npm config set sets npm environment variables which yarn can also utilize. In this particular case we are setting the proxy environment variables. Now simply try running the create-react-app command again and it should be able to proceed with setting up the new react project for you.

Hopefully that helps!

@DoctorAMDC
Copy link

Nope, I tried everything above and nothing works. My mentor will visit me to see what is happening

@DevRish
Copy link

DevRish commented Mar 18, 2022

I am facing the same issue. Please check this out : https://github.com/DevRish/martcart/issues/1 I have described my problem completely there...

@alancarltaylor
Copy link

I had this same issue, I was able to fix this by refactoring my setupProxy.js file to follow this format:

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(
    '/api', // <-- or whatever path segment precedes your server side routes
    createProxyMiddleware({
      target: 'http://localhost:5000', // <-- or whatever your proxy endpoint is
      changeOrigin: true,
    })
  );
};

More info can be found here: https://create-react-app.dev/docs/proxying-api-requests-in-development/

@zijianjoy
Copy link

I have the same issue, but I don't think it is related to proxy configuration. I have removed proxy configuration in package.json, I think the react-scripts start should at least show a html file without any server side data. Instead, it is localhost refused to connect.. I am using react-scripts: "5.0.0"

@FelipoCruz
Copy link

Hi, I have the same problem, and I have tried several solutions, but can't figure out why I still get the same:

image

Here is a screenshot of my terminal after running rpm start:

image

Any idea what is wrong? Thanks in advance!

@phoenixy1
Copy link

This was driving me insane when trying to upgrade a project from react-scripts 4 to 5. @alancarltaylor's fix worked. THANK YOU.

@ZeeshanAltaf
Copy link

Facing the same issue. Local Host refused to connect. attached is the error I see in my VS CODE
Screenshot 2023-04-12 131123

@hemanthnallamothu7777
Copy link

I am facing the same issue. Please check this out : DevRish/martcart#1 I have described my problem completely there...

make sure that the npm is active to make it active open terminal and select the respective file by using the command cd filename and run the command npm start
-i hope this will help you

@murali317
Copy link

Hello there I am facing the exact issue. Kindly help me solve this and continue my react learning journey.
Screenshot (91)

@hemanthnallamothu7777
Copy link

hemanthnallamothu7777 commented Jun 5, 2023

Open prompt and select the folder using command cd filename and run the command npm start and also check your node version

@murali317
Copy link

murali317 commented Jun 5, 2023

Bro, exact same content is showing in CMD also. What to do bro? @hemanthnallamothu7777

@MkLHX
Copy link

MkLHX commented Mar 22, 2024

For me, the issue turned out to be related to having mode code on a file share. When I move the code to the hard disk, it worked.

thank you I know why I'm stuck for weeks with projects! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests