25 Jul 2013

Error: That port is already in use

I was having a trouble to restart a Django server. At first time , i started a server like
>>python manage.py runserver 192.168.1.5:8000
no problem it started running fine.

I had to change the models so i exit the server using ctrl-Z and issue command to create the tables
>>python manage.py syncdb

Now when i tries to again start the server by issuing
>>python manage.py runserver 192.168.1.5:8000 again ,
it returns error message Error: That port is already in use.

This error means that port is already in use and to use same port , first we needs to kill process running on that port. Which involves following two steps :

1. Finding process for port 8000
  >>sudo netstat -lpn |grep :8000
this will return something like:
tcp        0      0 192.168.1.5:8000    0.0.0.0:*        LISTEN      10797/python   

here 10797 is a process id running on port 8000.

2. Kill the process
   >>kill -9 10797

Now
>>python manage.py runserver 192.168.1.5:8000 
would start the server again successfully.



No comments:

Post a Comment