Reputation: 1479
I ran python manage.py runserver
and the website was running at http://127.0.0.1:8000/
. I closed the terminal window running the server, reopened terminal and tried to run python manage.py runserver
again, but it says Error: That port is already in use
. I can't quit the server with Control-C
like I normally do, so I am not sure what do to here? Thanks for any help.
Upvotes: 2
Views: 1138
Reputation: 3392
Follow these steps to kill the server that's running.
$ lsof -i :8000
8000 is the port. So, if your using django and you run python manage.py runserver it's likely your port will be "8000"
That command will yield something like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 1158 biju 3u IPv4 0x4ae303085ae91559 0t0 TCP localhost:irdmi (LISTEN)
Except under "biju" it would have your username. Do you see the value under "PID" this is the number you need. Now you just kill that process.
$ kill -9 1158
Let's do that one more time:
$ lsof -i :8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 4894 biju 3u IPv4 0x4ae3030864c1dd41 0t0 TCP localhost:irdmi (LISTEN)
$ kill -9 4894
And that's it. You can kill this server without an error running.
Upvotes: 5