How to kill a currently using port on localhost in windows?[TOP]

you can use port 5000, no 4000 in hexo, like this

1
hexo s -p 5000

Step 1

Run command-line as an Administrator. Then run the below mention command. type your port number in yourPortNumber

netstat -ano | findstr :yourPortNumber

1
2
3
C:\Users\yaokunyi>netstat -ano | findstr :35729
TCP 0.0.0.0:35729 0.0.0.0:0 LISTENING 5396
TCP [::]:35729 [::]:0 LISTENING 5396

See the PID ? In here the port is 5396 (process identifier)

Step 2

Then you execute this command after identify the PID.
(/F forcefully terminates the process)

taskkill /PID typeyourPIDhere /F

1
2
C:\Users\yaokunyi>taskkill /PID 5396 /F
SUCCESS: The process with PID 5396 has been terminated.

P.S. Run the first command again to check if process is still available or not. You’ll get empty line if process is successfully ended.


By stackoverflow

近期频繁使用gitbook,发现gitbook有时会出现端口被占用的问题无法启动服务,也是郁闷到底是谁占用的。