Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active December 5, 2018 22:33
Show Gist options
  • Save harrisonmalone/ea5f5278c800353f3a730fb8650dfdb5 to your computer and use it in GitHub Desktop.
Save harrisonmalone/ea5f5278c800353f3a730fb8650dfdb5 to your computer and use it in GitHub Desktop.

Killing a process

when needing to run a mongodb server and another port is running for some weird reason

lsof -i :27017

this displays the pid

COMMAND  PID    USER     FD  TYPE      DEVICE        SIZE/OFF NODE      NAME
mongod  17381 rosssavill 9u  IPv4 0x38d7c23ab2a3b0f7  0t0     TCP localhost:27017 (LISTEN)

to kill the process

kill -9 17381

now if i run

lsof -i :27017 

no value is returned which means the process has been killed

the same applies to any port that's running, we just need to know it's port number and apply the steps above

more about how to kill processes online

it actually shows that once you have the pid you can just run the kill command

to fix the stale pid problem to do with postgres follow these instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment