![Post Banner Post Banner](https://code2care.org/linux/kill-service-port-on-ubuntu-linux/images/Post Banner.jpg)
If you have a service running on a port on your Ubuntu Linux Server and want to kill it, you can achieve it by using the kill command,
Step 1: Identify the service running and get its Process Id (PID)
Syntax: sudo lsof -I:{PORT}# sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 2785 root 6u IPv4 39198 0t0 TCP *:89 (LISTEN)
nginx 2785 root 7u IPv6 39199 0t0 TCP *:80 (LISTEN)
As you can see I have made use of lsof command to see if I have my Nginx localhost server running on the device
Step 2: Kill the Service on the port using PID
Syntax: kill -9 {PID}kill -9 2785
Kill the service in one single line
sudo kill -9 $(sudo lsof -t -I:{PORT})
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Ubuntu,
- Fix - sudo: systemctl: command not found
- How to know the version of Ubuntu
- [Fix] Ubuntu E: Unable to locate package sudo error
- How to install Apache Maven on Ubuntu
- Steps to Kill a Running Process in Ubuntu Linux
- How to know current Ubuntu Linux version via terminal command
- How to stop/start/restart apache server using command [Ubuntu]
- Fix: Ubuntu (Linux) - bash: sudo: command not found error
- Ubuntu: How to search for a package to install using apt in Terminal
- Fix: E: Command line option --installed is not understood in combination with the other options
- How to install Python on Ubuntu
- Ubuntu Linux: How to Login as root User
- Access Windows share folder in Ubuntu Device in Network
- Add a User as a Sudoer Using Ubuntu Linux Command Line Terminal
- Install Oh My Zsh on Ubuntu Docker complete steps
- Fix: Make makefile:31 Error 127 (GCC)
- [fix] openssl No such file or directory error C++
- How to install zsh shell on Ubuntu
- Install Golang (Go) on Ubuntu
- Ubuntu Linux: Unzip a zip file using Terminal
- Where are Environment Variables stored in Ubuntu
- apt-get list --installed packages in Ubuntu Linux
- Ubuntu: List all Installed Packages using apt
- Quick steps to install Nginx on Ubuntu Linux
- How to kill service running on a port on Ubuntu Linux
More Posts:
- JavaScript : Get current page address - JavaScript
- fix macOS: The digital signature on the update is missing or invalid. Ventura - MacOS
- Must have CSV Plugins for Notepad++ - NotepadPlusPlus
- Excel Fix: SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted. - JavaScript
- How to install SpaCy (NLP Library) on Mac - Python
- How to Rename Docker Image with none TAG and REPOSITORY? - Docker
- Restore deleted Office 365 SharePoint group site - SharePoint
- List of 32 CSS cursors web developers must know about - CSS