I have encountered a very weird situation. I am using below command to list all processes running on a particular port 3001:

sudo lsof -n -i :3001

Only one process is printed each time and I kill that process using sudo kill -9 pid. But as I run the lsof command again, i again notice that there is one more process with some random Pid. I delete it as well and the process goes on. It means my port is never free. How do I kill all process on this port?

Thank You!

  • process is not very descriptive. Which process exactly? It might be a daemon that keeps getting restarted - in that case, kill is not the right approach.
    – Panki
    Dec 7, 2020 at 8:33
  • Actually I was trying to start npm module json-server but it couldn't start. I tried 5-6 times. No as I run ps -ef, I see the json-server running process( actually it is not running) with a pid. Then I kill it using that pid. But as I run ps -ef again, it again appears with a different pid. I kill it again. This process is never ending. Dec 7, 2020 at 10:42
  • What I basically want to do is to free my port 3001. I process of freeing it, found the above stated problem. Now you please tell me how to free my port 3001. Dec 7, 2020 at 10:43
  • Stop the daemon (service) which keeps restarting json-server. I don't know your system or what daemons you are running.
    – Panki
    Dec 7, 2020 at 10:58
  • 1
    facing same situation and no command works, tried everything available in the internet
    – Atiq Baqi
    Jun 29, 2022 at 8:11

1 Answer 1


Run : systemctl status Will give you all services that starts on system start and these are daemon services. Figure out which service could be using that port(3001) and stop it using sudo serivce 'servicename' stop.

  • Welcome to the site, and thank your for your contribution. Please note however that this only works if the process is actually started using systemd, and not some other auto-start mechanism (or a manually started program that re-spawns child processes listening on that port if previous ones are killed).
    – AdminBee
    Mar 27, 2023 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .