DEV Community

Cover image for How to clear port 8080 in windows
Dedar Alam
Dedar Alam

Posted on Edited on

How to clear port 8080 in windows

How to Free Up a Port on Windows

If you've ever tried to start a local server and been greeted with an error like "port already in use," you're not alone. It usually means another process is still holding onto that port — often a leftover dev server that didn't shut down properly. Here's a quick, reliable way to find and kill it using the Windows command line.

Step 1: Find the Process Using the Port

Open Command Prompt (cmd.exe). You may need to run it as an administrator, though this isn't always required.

Run the following command, replacing <Port Number> with the port you're trying to free up:

netstat -ano | findstr <Port Number>
Enter fullscreen mode Exit fullscreen mode

This lists any active connections on that port, along with a PID (Process ID) — the number you'll need in the next step.

Example

Let's say something is hogging port 18080:

netstat -ano | findstr 8080
Enter fullscreen mode Exit fullscreen mode
TCP  0.0.0.0:18080    0.0.0.0:0     LISTENING    19788
TCP  [::]:18080       [::]:0        LISTENING    19788
Enter fullscreen mode Exit fullscreen mode

Here, the PID is 19788.

Step 2: Kill the Process

Now use taskkill to terminate that process:

taskkill /F /PID <Process Id>
Enter fullscreen mode Exit fullscreen mode

Following the example above:

taskkill /F /PID 19788
Enter fullscreen mode Exit fullscreen mode
SUCCESS: The process with PID 19788 has been terminated.
Enter fullscreen mode Exit fullscreen mode

And that's it — the port is now free to use again.

A Quick Word of Caution

Before killing a process, double-check what it actually is, especially if you're working on a shared machine or aren't sure what's running. Killing the wrong process can close unsaved work or disrupt something you didn't mean to touch.


Source: CodeGrepper

Top comments (1)

Collapse
 
moopet profile image
Ben Sinclair

The area circled in red shows the PID (process identifier

There's no area circled in red.