Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
515
rated 0 times [  515] [ 0]  / answers: 1 / hits: 886209  / 1 Year ago, sat, march 11, 2023, 4:53:08

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?


More From » networking

 Answers
5

Open your terminal and type as



lsof -i :8000


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):



$ lsof -i :8000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python3 3269 user 3u IPv4 1783216 0t0 TCP *:8000 (LISTEN)


And port 22 (SSH):



$ sudo lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 998 root 3u IPv4 1442116 0t0 TCP *:ssh (LISTEN)
sshd 998 root 4u IPv6 1442118 0t0 TCP *:ssh (LISTEN)


Hope that helps.


[#31873] Saturday, March 11, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
barted

Total Points: 424
Total Questions: 103
Total Answers: 101

Location: Djibouti
Member since Sun, Feb 27, 2022
2 Years ago
barted questions
;