Skip to content

Commit 9fafd2e

Browse files
Merge pull request #48 from keithamus/DOC/find-and-destroy-running-script
ADD tip about killing running processes
2 parents 41d2006 + 0182e20 commit 9fafd2e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Find and destroy running script
2+
3+
## Notes
4+
5+
I wrote this while using Mac OS Sierra, I believe that commands might not work on Windows (it may work on Linux).
6+
7+
Feel free to propose pull requests if you want to contribute to this documentation!
8+
9+
## Instructions
10+
11+
If you happen to get an error concerning a port which is already taken by a running process and that you did not get this error the first time you launched the script, chances are that the script is still running in the background and still using its chosen port...
12+
13+
### Find if the port is still being used
14+
15+
You can show all the network statistics using the command `netstat` in your Terminal:
16+
17+
```
18+
$ netstat -vanp tcp
19+
20+
Active Internet connections (including servers)
21+
Proto Recv-Q Send-Q Local Address Foreign Address (state) rhiwat shiwat pid epid
22+
tcp4 0 0 127.0.0.1.12443 127.0.0.1.64412 ESTABLISHED 405801 146988 335 0
23+
tcp4 0 0 127.0.0.1.54905 *.* LISTEN 131072 131072 46725 0
24+
tcp4 0 0 10.0.38.33.49695 54.77.194.154.443 TIME_WAIT 131072 131768 46723 0
25+
26+
(...)
27+
```
28+
29+
You will probably get a very long list and the easiest way to filter this out is to pipe your last command with `grep` + what you are looking for...
30+
Let say the port already used is `54905`, you would run:
31+
32+
```
33+
$ netstat -vanp tcp | grep 54905
34+
tcp4 0 0 127.0.0.1.54905 *.* LISTEN 131072 131072 46725 0
35+
```
36+
37+
### Manually `kill` the process
38+
39+
When running `netstat -vanp tcp`, the columns titles are shown.
40+
41+
Spot the `pid` column in the output... In our example the `pid` value for the process using the port `54905` is `46725`...
42+
43+
Just run `kill 46725` and make sure it worked by running `netstat -vanp tcp | grep 54905`.

0 commit comments

Comments
 (0)