How to find and kill the process using a port on Linux
First find the process ID (PID) that owns the port, for example 8080:
ss -ltnp | grep :8080 # or lsof -i :8080
Then stop it politely:
kill <PID>
If it does not exit, force it:
kill -9 <PID>
kill sends SIGTERM by default, which lets the program clean up. -9 sends SIGKILL, which cannot be caught, so use it last. You may need sudo for processes owned by other users. Before killing, check what the process is with ps -p <PID> -o cmd.