Иногда бывает ситуация когда 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
🪐 Astronomers used an exploding star, supernova SN 1987A in the Large Magellanic Cloud (about 168,000 light-years away), to precisely measure the speed of light across vast space. Light and ghostly particles called neutrinos from the explosion reached Earth just hours apart, providing real proof that even over intergalactic distances, light always travels at the same constant speed—299,792 kilometers per second. ✨
#speedoflight⚡#supernova⚡#LargeMagellanicCloud⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In the Tarantula Nebula of the Large Magellanic Cloud, light from young, massive stars races outward at the universal speed limit—299,792 kilometers per second—helping illuminate vast clouds of gas across 1,000 light-years of space. Because nothing can travel faster than this speed in a vacuum, the glow we see from such stellar nurseries is always an echo from the past, showing us cosmic events exactly as they unfolded years, decades, or even millennia ago. ✨
#speedoflight⚡#tarantulanebula⚡#largemagellaniccloud⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries