Kill Port Process on Synology Diskstation (Linux)

Every now and again, my Django server will time out, but when attempting to restart I’m faced with the following error:

Error: That port is already in use.

Most solutions out there – such as using the fuser command – were of no help as Synology’s OS is pretty vanilla. I was able to find a solution though on Stack Overflow:

First run the following to retrieve your Port Id (PID):

$ ps aux | grep -i manage

This will return something like the following:

$ user <PID>  ... /volume1/web/bryanhadro_django_project/venv/bin/python runserver

Or for example:

$ user 12345  1.3  5.2 893874 84987 pts/12   Sl+  06:45   0:47 /volume1/web/bryanhadro_django_project/venv/bin/python runserver

Where the first number after your username – 12345 – is the PID. Using that number, all we need to do is run /bin/kill <PID>:

$ /bin/kill 12345

You should now be good to restart your Django server!

Leave a comment

Your email address will not be published. Required fields are marked *