1

I have a React app made using create-react-app. I've been running this app without any issues for a few months now but have recently ran into an issue with starting the app because it says the port is in use. Here is the error message: Something is already running on port 3000. I'm trying to run the app on a Windows 10 machine.

Everything I've tried so far is listed below:

  • Running netstat -an and checking the output. This shows nothing running on port 3000.
  • Running netstat -an | findstr "3000". This shows no output.
  • Running npx kill-port 3000. I still get the port in use error message after running this.
  • Changing port that the app is running on. It doesn't matter which port I choose, it always says the port is in use.
  • Checking the Listening Ports list in Resource Monitor shows nothing listening on port 3000
  • Restarting my PC

The only thing that works is running the app in a Ubuntu 20.04 VM... which seems to indicate there's something listening on port 3000 on my Windows machine. However, I'm not sure what else I can do to troubleshoot this issue. I'm looking for suggestions on what else I could try.

Edit

Here's the contents of my hosts file C:\Windows\System32\drivers\etc\hosts:

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
# Added by Docker Desktop
192.168.2.115 host.docker.internal
192.168.2.115 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
Clunis
  • 55
  • 1
  • 6
  • 1
    Windows firewall maybe ? – IluSioN Aug 23 '22 at 15:05
  • 1
    can you pls check in your host file for localhost what is values will be there? C:\Windows\System32\drivers\etc\hosts – R.G.Krish Aug 23 '22 at 15:18
  • @RGKrish183 I edited my post and added the contents of my hosts file. FYI docker is not currently running on my system. Is there anything in particular I should be looking for? Thanks. – Clunis Aug 23 '22 at 18:21
  • @IluSioN What should I be looking for in the Windows Firewall? Sorry if that's a stupid question, I don't know much about the Windows Firewall. – Clunis Aug 23 '22 at 18:25
  • 1
    Might be a code problem, you could be trying to start the server twice (in code) and the first one works and the 2nd one crashes the whole thing because it tries to use the same port – apokryfos Aug 23 '22 at 20:28
  • I was able to resolve the issue by restarting the WinNAT service. I found the solution here: https://stackoverflow.com/questions/62508193/error-listen-eacces-permission-denied-0-0-0-03001. Thanks for your help everyone! – Clunis Aug 24 '22 at 14:13

2 Answers2

2

I resolved the issue by restarting the WinNAT service. I found the solution in the answers here: Error: listen EACCES: permission denied 0.0.0.0:3001

These are the steps:

  1. Start Command Prompt or PowerShell as Administrator
  2. Stop WinNAT with this command: net stop winnat
  3. Start WinNAT again with this command: net start winnat
Clunis
  • 55
  • 1
  • 6
0

You can change it like below and try again, I'm not sure try once:

FYI, C:\Windows\System32\drivers\etc\hosts

Change to,

# localhost name resolution is handled within DNS itself.
    127.0.0.1       localhost
    ::1             localhost

Instead of below this:

127.0.0.1 kubernetes.docker.internal
R.G.Krish
  • 487
  • 5
  • 22