How to kill process on a port in Ubuntu

When you run this command to kill specific port in ubuntu
sudo kill 'sudo lsof -t -i:9001'
you may get this error message

ERROR: garbage process ID "lsof -t -i:9001".
Usage:
  kill pid ...              Send SIGTERM to every process listed.
  kill signal pid ...       Send a signal to every process listed.
  kill -s signal pid ...    Send a signal to every process listed.
  kill -l                   List all signal names.
  kill -L                   List all signal names in a nice table.
  kill -l signal            Convert between signal numbers and names.

To solve this problem you can try this command

sudo kill -9 `sudo lsof -t -i:9001`

sometimes doesn’t work you can also try this command

sudo kill -9 $(sudo lsof -t -i:9001)