Bash shell

List all processes bound to a specific port

lsof -i:8080

Kill or terminate a process by the port it’s bound on

# Kill
lsof -ti tcp:<port> | xargs kill -SIGKILL

# Terminate
lsof -ti tcp:<port> | xargs kill -SIGTERM

Wait for a process to start and bind to port

export SERVER_PORT=8080
mvn spring-boot:run -Dserver.port=${SERVER_PORT} &
while ! echo exit | nc localhost ${SERVER_PORT}; do sleep 4; done