localhost:3000 is not working in the browser [closed]
Asked Answered
M

6

10

Backend: Express server, with npx create-express-api backend

Frontend: Next.js, with npx create-react-app frontend

I have implemented these command in my root folder and trying to run npm start xxx to check if they are still working or not. But they are not working in my http://localhost:3000 Though they are working in this link http://172.27.178.192:3000 (on my network) This is the image showing the problem

I have changed browsers and still the same problem is appearing. On the browser it says Unable to connect Firefox can’t establish a connection to the server at localhost:3000.

Mureil answered 24/12, 2020 at 10:20 Comment(7)
Did you check if it works on other browsers like Chrome?Ernestinaernestine
Yes, I also tried in chrome. Its the same with chromeMureil
Perhaps you have some entries in the hosts file that break the usual behaviorReese
Should I cange the hosts file? How should I change itMureil
Is this being run in a virtual machine or directly? If in a virtual machine localhost will only work within the machine.Primogeniture
@PatrickEvans It is being run directlyMureil
@HassanMahmud, Here are about host files: - Window C:\Windows\System32\drivers\etc\hosts - Linux /etc/hostsPostmortem
C
6
netstat -ano | findstr :8080

Then the PID will appear at the right which you can kill with taskkill.

The last number the pid. enter image description here

then:

taskkill/pid 11704 /F

How to close TCP and UDP ports via windows command line

Craps answered 24/12, 2020 at 12:47 Comment(3)
Which code editor or IDE use? My experinece about visual studio code sometimes stuck. I search the problem but not found. After reinstalled work evertyhing fine.Dolly
I think wort it try reinstall. Yet happpened me that not find a file the correct path because behind the scenes visual studio code spolied this file reference(after file was renamed)Dolly
Thanks for the msg. Tried it by reinstalling. Didn't work. I don't know, its just if there is any problem somewhere and I can't even find it. Kind of frustrating to be a newbie (•‿•)Mureil
C
2

I think some other application occupied your 3000 port. try find which one is. If you have found then closed and try again.

For instance you want to free the port 3000 Then, follow these commands.

netstat -ano taskkill /f /im [PID of the port 3000 got from previous command]

How to close TCP and UDP ports via windows command line

Craps answered 24/12, 2020 at 12:39 Comment(0)
A
0
  1. in browser history search for localhost:3000 and delete all of them.
  2. make sure you closed all terminalls(check vscode too) and all tabs in your browsers.
  3. in new widnows terminal npx kill-port 3000 do it in WSL2 terminall too.
  4. make sure your firewall is turn of.
  5. restart you computer.
Affirmative answered 21/4, 2022 at 13:49 Comment(0)
V
0

In my case, Waterfox/Firefox was configured to disable IPV6 in about:config

network.dns.disableIPv6

Once I set it back to false which is the default it works. It is likely that localhost is mapped to ::1

Vallejo answered 4/7 at 4:22 Comment(0)
N
-1

It worked for me

  1. Delete the .next folder ( if your working on nextjs ) and try npm run dev command OR

  2. Move the project to another folder location OR

  3. Take back up of the code and delete the project and then run the same project again

  4. You can try all of the above also

Newsletter answered 8/11, 2022 at 9:0 Comment(0)
U
-1

If you still have this problem and none of the above helps. Try my solution. I used http-proxy-middleware and deleted setupProxy.js -> npm start -> restore proxy, and it worked like a champ.

Unweave answered 8/7, 2023 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.