node.jsreactjswindowsreact-app-rewired

Port 3000 always taken (even if I override it with PORT=XYZ)


I have a WEB app written in React and whenever I try to run it with react-app-rewired start it complains that Something is already running on port XYZ.

I've checked if any process is listening on port XYZ with netstat -a -b, but there was none. Also, if I change port XYZ to any 4 digit value (with environment variable PORT=3001), I'll always get the same problem, that the port is already taken, so I'm concluding that port is not taken but something is going on down under. I'm running on Windows 10 with Node 12 Installed (I tried downgrading to node 10 because I think this used to work for me on lower node version, but I couldn't get it working anymore).

I've searched the web and most of them suggest checking if port is taken, few other I found are bellow but didn't work for me:

Did anyone had similar problems and was able to resolve them?


Solution

  • It turns out it was Hyper-V taking all the ports....After disabling Hyper-V I was able to run node app on port 3000.

    Workaround for this issue is to reserve ports while Hyper-V is turned off:

    1. Disable hyper-v (which will required a couple of restarts)

    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

    1. When you finish all the required restarts, reserve the port you want so hyper-v doesn't reserve it back

    netsh int ipv4 add excludedportrange protocol=tcp startport=3000 numberofports=1

    1. Re-Enable hyper-V (which will require a couple of restart)

    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

    References: