Иногда бывает ситуация когда 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
🌍 In Shenzhen, China, nearly all public buses and taxis run on electricity, making it the world’s first major city to fully switch its urban transit fleet to electric vehicles. ✨
#urbangeography⚡#transport⚡#innovation⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 Melbourne, Australia, is regularly ranked as one of the world’s most liveable cities thanks to its blend of extensive parks, creative laneways, and a tram network that covers over 250 kilometers. ✨
#urbangeography⚡#citylife⚡#infrastructure⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 The world’s tallest residential building, Central Park Tower in New York City, rises 472 meters. Ultratall skyscrapers like this change city skylines and challenge how we design urban living spaces. ✨
#urbangeography⚡#skyscraper⚡#citylife⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
🌍 In Seoul, over half the city’s rooftops host gardens, solar panels, or small farms—turning unused urban spaces into green zones that cool neighborhoods and boost local food production. ✨
#urbangeography⚡#cityplanning⚡#greencities⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels