How to 'clear' the port when restarting django runserver

前端 未结 19 2187
盖世英雄少女心
盖世英雄少女心 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:51

    Happened so often that I wrote an alias to kill the process with python in the name (careful if you have other such processes). Now I just run (no Ubuntu)

    kill $(ps | grep "python" | awk "{print $1}")
    

    You can even add python manage.py runserver ... to the same alias so you can restart with two keystrokes.

提交回复
热议问题