How to 'clear' the port when restarting django runserver

前端 未结 19 2188
盖世英雄少女心
盖世英雄少女心 2020-12-12 11:23

Often, when restarting Django runserver, if I use the same port number, I get a \'port is already in use\' message. Subsequently, I need to increment the port number each t

19条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 11:55

    You do not want to simply increment the port number when restarting a Django server. This will result in having multiple instances of the Django server running simultaneously. A better solution is to kill the current instance and start a new instance.

    To do this, you have multiple options. The easiest is

    Python2: $ killall -9 python

    Python3: $ killall -9 python3

    If for some reason, this doesn't work, you can do

    $ kill where is the process id found from a simple $ ps aux | grep python command.

提交回复
热议问题