I suspect a program is listening on port 8000
on my machine.
When I run the following command, I get this error:
> python -m SimpleHTTPServer
# Lots of python error
socket.error: [Errno 98] Address already in use
If I use another port (8000
is the default), the web server runs fine.
If I run wget localhost:8000
from the command line, it returns 404 Not Found
.
What can I do (or what tools are available) to find what program is listening on port 8000
, and from there where that program is configured?
Open your terminal and type as
that command will list you the application used by that port with PID. (If no results run via
sudo
since your might have no permission to certain processes.)For example, with port 8000 (
python3 -m http.server
):And port 22 (SSH):
Hope that helps.
You can use netstat to see which process is listening on which port.
You can use this command to have a full detail :
if you need to know exactly which one is listening on port 8000 you can use this :
There is no process that can hide from netstat.
To expound on the answer by @33833 you can get some very detailed info, for example:
I can see right there that squid is the process, but it is actualy my
squid-deb-proxy
that is taking up the port.Another good example of a java app:
You can see in
lsof
(LiSt Open Files) that it is java, which is less than helpful. Running theps
command with the PID we can see right away that it is CrashPlan.Try
ss
fromiproute2
package:Another way using
socklist
fromprocinfo
package:man socklist
sudo socklist
Due to low point in community, I can't comment here. Without
sudo
all above commands will not provide you Process Id / Program Name.So, you need type following things:
or
you can check those command details via
man
,help
or my favorite helperYou can use nmap.
to install it, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command below:
For more information about nmap, and other utilities, go Here
1Source:garron.me
Here is an easy to remember command