title: Trying to kill process on port 8000 confusion
body: <p>I am writing a Ruby script that deploys a server on port 8000 in the background, and then in the foreground I issue queries to the server. After I've issued my queries I kill the server, however when I kill the server, it seems to be switching ports.</p>
  
  <p>I am doing it the following way in the ruby script:</p>
  
  <p>To see PID that is running on port 8000:</p>
  
  <pre><code>lsof -i:8000 -t
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>RUNNING ON PORT 8000: COMMAND   PID         USER   FD   TYPE DEVICE   SIZE/OFF NODE NAME
  java    26364 user1   84u  IPv6 199069      0t0  TCP *:8000 (LISTEN)
  </code></pre>
  
  <p>To kill the server I issue the command:</p>
  
  <pre><code>kill 26364
  </code></pre>
  
  <p>I then see if anything is running on port 8000: </p>
  
  <pre><code># check if killed
  lsof -i:8000 -t
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>  RUNNING ON PORT 8000: COMMAND   PID         USER   FD   TYPE      DEVICE SIZE/OFF NODE NAME
    ruby    25560 user1   58u  IPv4 199123      0t0  TCP                localhost:45789-&gt;localhost:8000 (ESTABLISHED)
    java    26364 user1   84u  IPv6 199069      0t0  TCP *:8000 (LISTEN)
    java    26364 user1   85u  IPv6 199124      0t0  TCP   localhost:8000-&gt;localhost:45789 (ESTABLISHED)
  </code></pre>
  
  <p>I only want to kill the process that is listening on port 8000,
  and keep my ruby script running.  </p>
  
  <p>Can someone please tell me what is going on? Why is it switching ports? How can I only kill my server port?</p>