First, find which PID is using the given port (replace 8080 with your own value):
lsof -t -i:8080This will give you a PID, like 12345.
Next, kill the process by id (again, replace the id with the result of the previous command):
sudo kill -9 12345You can also do it all in one command:
sudo kill -9 $(sudo lsof -t -i:8080)If for whatever reason something is not working, you can get more info about what processes are running using ps ax