VibeWare

Guides/Network

How to check what is using a port on Windows

The short answer

Run netstat -ano | findstr :8080 in Command Prompt, with your own port number. The last column is the process ID (PID) of the program that has the port, and tasklist /fi "PID eq 1234" turns that PID into a name. In PowerShell, Get-NetTCPConnection -LocalPort 8080 does the same job. If nothing shows up and the port still can't be used, Windows may have reserved it: check with netsh int ipv4 show excludedportrange protocol=tcp.

Find the PID with netstat

Open Command Prompt or Terminal. This lists every connection and listening port with the ID of the process behind it:

netstat -ano

-a shows all connections and the ports the PC is listening on, -n keeps addresses and ports as numbers, and -o adds the process ID. No administrator prompt is needed.

The list is long, so filter it for your port:

netstat -ano | findstr :8080

A line looks like this:

  TCP    0.0.0.0:8080    0.0.0.0:0    LISTENING    1234

The last number is the PID. findstr matches text anywhere on the line, so :80 also finds :8080 and :8000. Look at the local address column, the second one, to be sure you have the right line.

Turn the PID into a program

tasklist /fi "PID eq 1234"

That prints the image name, such as node.exe. If the name is svchost.exe, add /svc to see which Windows services run inside that process:

tasklist /svc /fi "PID eq 1234"

You can also look the PID up in Task Manager.

netstat -anob prints the program name under each line in one go. It needs an administrator prompt and is slow.

The same in PowerShell

Get-NetTCPConnection -LocalPort 8080

The OwningProcess column is the PID. To get the name in the same line:

Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess

For UDP, which Get-NetTCPConnection does not cover:

Get-NetUDPEndpoint -LocalPort 53

Stop the program

Closing the program the normal way is always the better choice. If that is not possible:

taskkill /PID 1234

This asks the process to end. With /F it is ended by force:

taskkill /PID 1234 /F

A forced end is immediate, and anything the program had not saved is lost. In PowerShell, Stop-Process -Id 1234 stops the process. To stop a process that belongs to another user or to Windows, you need an administrator prompt. Do not end a PID before you know what it is.

If it is a file and not a port that a program will not let go of, see how to find which process is locking a file.

Port 80 or 443 held by System

If the PID is 4, the owner is System: Windows itself. taskkill is not the answer here.

Windows has an HTTP service of its own. Programs can use it to receive web requests instead of opening the port themselves, and the port then belongs to System. To look at it, run:

netsh http show servicestate

It prints a snapshot of the HTTP service. Add view=requestq to see only the request queues. The fix is to stop or reconfigure the program or Windows feature that registered there, not to end System.

The port is in use, but nothing is listening

You get “address already in use” or “access forbidden”, and netstat -ano shows nothing on that port. There are two usual explanations.

Windows has excluded the port. Windows can keep ranges of ports away from programs. List them with:

netsh int ipv4 show excludedportrange protocol=tcp

Use protocol=udp for UDP. If your port is inside one of the ranges, binding it typically fails with Winsock error 10013 (WSAEACCES, permission denied), not with the “already in use” error 10048 (WSAEADDRINUSE). The error number your program reports is a good hint to which case you have.

A program has bound the port without listening. A socket can hold a port before it listens, or without ever listening. Add -q to see those:

netstat -anoq

-q adds bound non-listening TCP ports to the list.

Why excluded ranges land on development ports

Windows hands out ports for outgoing connections from a dynamic range. By default it starts at 49152 and ends at 65535. Check yours:

netsh int ipv4 show dynamicport tcp

If the start port is something else, the dynamic range, and what gets carved out of it, can overlap ports that development tools like to use. In an administrator prompt, you can set it back to the default:

netsh int ipv4 set dynamicport tcp start=49152 num=16384

This changes a system-wide setting, so only run it if the current range is the cause of your problem. There are separate ranges for UDP and for IPv6 (int ipv6).

With VibePort

VibePort shows the same tables in a window, with the lookups already done. It is a free, open-source preview and needs no administrator rights.

  • The Ports tab lists every TCP and UDP endpoint with its process name and PID, refreshed every second.
  • Type a port number in the filter and it answers in a sentence: which process has it and how it was started, that Windows reserves it, that something holds it and no table shows what, or that nothing on this PC uses it.
  • The Reserved tab lists the excluded ranges, says whether each was set by an administrator or taken at runtime, and warns when the dynamic range starts below 49152.
  • End process asks first, and refuses to end a process Windows can’t run without.

It reads the reserved ranges with the same netsh commands as above. It does not change them, and it does not close a single connection.

Questions people ask

How do I find which process is using port 8080 in Windows?

Run netstat -ano | findstr :8080 and read the PID in the last column. Then run tasklist /fi "PID eq" with that number to get the program's name. In PowerShell, Get-NetTCPConnection -LocalPort 8080 shows the same PID as OwningProcess.

How do I kill the process on a port in Windows?

Find its PID with netstat -ano, then run taskkill /PID 1234 with that PID. Add /F to force it. The program ends at once and loses anything it had not saved, so check what the PID is before you end it.

Why does Windows say port 80 is in use by System?

PID 4 is System, which is Windows itself. Windows has an HTTP service of its own that programs can receive web requests through, so the port is held by System on their behalf. Run netsh http show servicestate to see a snapshot of that service.

Why is the port already in use when nothing is listening?

Either Windows has excluded a range that contains the port, or a program has bound it without listening. netsh int ipv4 show excludedportrange protocol=tcp shows the first, and netstat -anoq shows bound ports that are not listening.

Do I need administrator rights for netstat?

Not for netstat -ano. The -b switch, which prints the program's name directly, fails unless you have sufficient permissions, so it needs an administrator prompt.

Sources

VibeWare is not affiliated with Microsoft. What this page says about them comes from their own pages, linked above.

Published · by Ted K. Johansen, who also makes VibePort

More guides