How to Quickly Identify and Kill Applications Occupying a Port on Windows
When running a web or backend application on Windows, you may encounter the error “port already in use” (e.g., port 8080 already in use). This guide explains how to identify which application is using the port and terminate it quickly via command line, without external tools.
Step 1: Identify the Application Using the Port
Open Command Prompt (CMD) or PowerShell and run:
netstat -ano | findstr :portNumber
Replace portNumber with the port number to check (e.g., 4200, 8080).
<image>
The output will display connections using the port. The last column shows the PID (Process ID) of the process.
Step 2: Kill the Process
Terminate the process using its PID:
taskkill /PID yourPID /F
Replace yourPID with the PID obtained above.
<image>
If successful, you will see:
SUCCESS: The process with PID xxxx has been terminated.
Additional Notes
- To check which application corresponds to a PID, run:
tasklist | findstr yourPID
- Be cautious: avoid terminating unknown system processes.
Conclusion
By identifying and terminating processes occupying ports, you can quickly resolve runtime errors and continue developing without restarting your system.