Situatie
The “port already in use” error is common with web servers, databases and development tools. The fix is to identify the process that holds the port.
Solutie
- Press the Windows key, type
cmd, right-click Command Prompt and select Run as administrator. - Search for the port you need (example for 8080):
netstat -ano | findstr :8080
- In the output, the last column is the PID of the process (for example
4812). - Find the name of the process:
tasklist /FI "PID eq 4812"
- If the process can be safely stopped, terminate it:
taskkill /PID 4812 /F
- Run the command from step 2 again. If nothing is returned, the port is free.
PowerShell alternative:
Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalPort, State, OwningProcess
Get-Process -Id 4812
Warning: do not terminate system processes (such as System or svchost.exe) unless you know which services run inside them. If the port is held by a Windows service, stop the service from services.msc instead.
Leave A Comment?