Skip to content

"Process using port" on windows #12509

@ariccio

Description

@ariccio

Is your proposal related to a problem?

This was mentioned in Issue #441 and #454 and pull #816. Someone suggested windows doesn't need support for nice things, and I disagree. mimes shaking fist at clouds

Describe the solution you'd like

Windows support would be nice! It's a tiny little thing, but it would be nice :)

The relevant code is here.

The option to support this that is most similar to the current functionality for Linux and MacOS would be to use the classic Command Line with netstat, or to use some fancy schmantzy powershell. They're both shown in a stackoverflow answer.

Describe alternatives you've considered

Alternatively, you could use the win32 api function GetExtendedTcpTable in Iphlpapi.dll. As someone with a background in C and C++, and am still one at heart, this would be my preference, but it would require much more work and code.

Additional context

Two things.

  1. Is there a reason why react-scripts doesn't automatically just choose a different port? I assume this is a tooling thing. It would be neat if I could change an option so it switches ports by default.
  2. I thought I filed an informational bug for this one a while ago, but I guess I never did. Sometimes a port will show up as NOT USED by any process on Windows 10+, but no program can open it. They will get a EACCESS error, and be confused. The cause is that the port is EXCLUDED/RESERVED, not in use. Someone should note this somewhere, because occasionally port 3001 won't work either. It's surprising. To check if the port is reserved, you need to run netsh interface ipv4 show excludedportrange protocol=tcp, and see if the range is in the list - Hyper-V sometimes reserves the port. The only way I know to recover from this is to reboot the system and check if its reserved again. And continue rebooting until the port is not reserved. It is annoying, and I'm sure this tidbit will help someone!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions