Results 1 to 9 of 9

Thread: netstat shows processes listening on port, but no PID?

  1. #1
    Join Date
    Apr 2007
    Beans
    278

    netstat shows processes listening on port, but no PID?

    I started a process that listens on port 8080. It is a testing environment for Django. I use Putty to SSH into my linux box and run this process.

    After starting this process, I left my computer for a bit. When I returned I found that the Putty connection had been closed. No biggy, I just logged back in on a new connection. However, now when I try to run that process again, I can't because the port 8080 is already in use. I believe that the original process is still active, still listening on port 8080.

    How can I kill it?

    I tried a bunch of different commands to determine the PID all with no luck. Here's one example:

    Code:
    sudo netstat -atnp
    
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 192.168.1.130:8080      0.0.0.0:*               LISTEN      -
    Why no PID?! How do I figure this out? I need to kill the process.

  2. #2
    Join Date
    Jan 2012
    Beans
    1

    Re: netstat shows processes listening on port, but no PID?

    You want to do a

    Code:
     
    lsof -i:8080 -n
    That will list the process id of anything using that port .

  3. #3
    Join Date
    Apr 2007
    Beans
    278

    Re: netstat shows processes listening on port, but no PID?

    Quote Originally Posted by janushost View Post
    You want to do a

    Code:
     
    lsof -i:8080 -n
    That will list the process id of anything using that port .
    There is no output when I run that command. But still, if I try to fire up my program that uses port 8080, it says it's in use.

  4. #4
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: netstat shows processes listening on port, but no PID?

    If the service is something that is handled in the kernel like NFS then there will not be a PID/Program listed.

    What is the app/process you started?

  5. #5
    Join Date
    Apr 2007
    Beans
    278

    Re: netstat shows processes listening on port, but no PID?

    Quote Originally Posted by hawkmage View Post
    If the service is something that is handled in the kernel like NFS then there will not be a PID/Program listed.

    What is the app/process you started?
    It's the test server for Django -- I'm building a web app. The test server is like a mini apache server, listening on port 8080 on my local machine's IP address.

  6. #6
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: netstat shows processes listening on port, but no PID?

    Since you are running it under "a mini apache server" I assume that it is using python to bind to the port. If so are there any python processes running? I am not sure if it spawns a process that binds to the port of not. I not familiar with Django.

  7. #7
    Join Date
    Apr 2007
    Beans
    278

    Re: netstat shows processes listening on port, but no PID?

    Quote Originally Posted by hawkmage View Post
    Since you are running it under "a mini apache server" I assume that it is using python to bind to the port. If so are there any python processes running? I am not sure if it spawns a process that binds to the port of not. I not familiar with Django.
    Ya, it uses Python. I suppose I could kill all Python processes, but that seems extreme....

  8. #8
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: netstat shows processes listening on port, but no PID?

    OK, what do you get if you run:
    Code:
    rpcinfo -p
    Is there an RPC entry using port 8080?

  9. #9
    Join Date
    Dec 2010
    Beans
    573
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: netstat shows processes listening on port, but no PID?

    Another idea is if you started the instance using the manage.py script supplying the port on the command line you could grep the proc files for the pot number like this:
    Code:
    grep -a '8080' /proc/*/cmdline
    If you get a match on /proc/self you can ignore that since it is just matching the grep argument.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •