2

I have a simple script for viewing the webpage I am working on.

import SimpleHTTPServer
import SocketServer
PORT = 8000 
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()

I've copied this script to a few directories with different index.html pages I am working on. I killed the server serving index_A (in its own directory, Development/A). However when I try to run the script in Development/B (which should serve index_B) it is still serving index_A.

Edit: When I change the port I am using, it serves the correct index. Still not sure why the old index shows up in the old port, even when I kill the process.

Andrew
  • 6,295
  • 11
  • 56
  • 95
  • Are you really killing the original (`A`) server process? Are you sure you've switched directories before running the `B` server? Have you confirmed--I mean really looked with fresh eyes to make sure--the content is where you think it is? Sorry to be blunt, but pilot error is the most likely explanation. – Jonathan Eunice Dec 02 '14 at 22:06
  • I used filip's solution here:http://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac to kill the process, would that not be sufficient? I am sure about running it in different directories. – Andrew Dec 02 '14 at 22:09
  • There are a lot of solutions there, but I assume you mean something like `kill -9 \`lsof -i :8000 | egrep -v PID | awk '{print $2}'\``, which should be reliable. – Jonathan Eunice Dec 02 '14 at 22:16

1 Answers1

6

I just had this same problem and it was very distressing and stubborn. Tried all the suggestions here and also here with commands freeport, netstat, ps, lsof and kill. Few hours later found that it was something more elementary. Even after several restarts the same index.html was still being served at 0.0.0.0:8000. But tried the other browsers and it was only happening in Chrome! so cleared the cache and it went away.

Community
  • 1
  • 1
cardamom
  • 6,873
  • 11
  • 48
  • 102