Иногда бывает ситуация когда dev-сервер по какой-либо причине не закрылся и висит в процессах, занимая порт.
Это может быть из-за падения IDE или просто сам забыл погасить и закрыл терминал.
Для таких случаев я набросал простую функцию с командой:
kill_on_port() {
port=$(lsof -t -i:$1)
echo "KILL PROCESS:" $port
sudo kill -9 $port
}
alias killonport="kill_on_port $@"
Код поместить в ~/.bashrc и рестартнуть систему.
Если во время старта dev-сервера получаете ошибку что порт уже занят, просто выполните команду, подставив свой порт.
Bash
kill_on_port 8000
Скорее всего бесполезно, если другой процесс назначен на перезапуск вашего dev-сервера в случае падения.
Имя команды можете изменить на любое другое.
#linux
#BREAKINGNEWS
🔴 US President Biden confessed
- Were these bombs that were stopped from being shipped to Israel used to kill civilians in Gaza?
+ They were previously used to kill civilians in Gaza and destroy population centers.
🚨
🚨
🚨#BREAKINGNEWS
The occupying Israeli army has launched a very violent attack on the east of Rafah as of now.
The attacked areas are the area that Israel demanded to be evacuated in the morning.
🚨#BREAKINGNEWS
The Kassam Brigades broadcast the moments of shelling the Israeli occupation forces with heavy caliber mortars in Netsarim, south of Gaza City.
🚨#BREAKINGNEWS
A Turkish youth staged a stabbing operation in Israeli-occupied Jerusalem, wounding an Israeli policeman. The youth was martyred. (Haaretz)