Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»How to Kill a Process Running on Specific Port

    How to Kill a Process Running on Specific Port

    By RahulJuly 22, 20221 Min Read

    The Linux operating system considers everything as a file. So first of all, use lsof (list of open files) Linux command to identify the process id (PID) of the running process on any port. Once you get the process id, you can use the kill command to kill that process using the PID.

    Advertisement

    Kill a Process Running on Port

    First of all, find out the PID (process id) of the running process on a specific port. For example, a process is running on port 3000. To find its process id, execute:

    lsof -t -i:300
    
    6279
    

    Now you have the PID of the process running on a port. Use the kill command to terminate that process by its PID.

    sudo kill -9 6279 
    

    You will notice that the process running on the specific port is terminated.

    Short Version of Command

    You can also combine both of the above commands and run it as follows:

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

    Conclusion

    In this faq, you have learned to terminate a process running on a specific port.

    kill lsof pid process
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    free Command in Linux (Check Memory Uses)

    A Practical Guide to Extracting Compressed Files in Linux

    TR Command in Linux: A Guide with Practical Examples

    TR Command in Linux: A Guide with Practical Examples

    View 1 Comment

    1 Comment

    1. Alvin on July 18, 2021 6:22 am

      fuser -n tcp -k #
      #means port number

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • A Comprehensive Look at the Simple Mail Transfer Protocol (SMTP)
    • Understanding Basic Git Workflow: Add, Commit, Push
    • The Difference Between Git Reset –soft, –mixed, and –hard
    • Understanding the Staging Area in Git’s Workflow
    • Python Function with Parameters, Return and Data Types
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.