1

I'm running a website on my local Mac (Lion) machine using Python's SimpleHTTPServer. I can view the site at http://localhost:8000 or http://127.0.0.1:8000 on my local machine.

My question is: why can't I view it on other machines connected to the same LAN?

I have taken the following steps:

  1. Enabled Web Sharing on my Mac, and temporarily turned off my firewall.
  2. Obtained my Mac's IP address via ifconfig: it is 192.168.1.13.
  3. Connected another machine to the same LAN.
  4. On that machine, pointed a browser at http://192.168.1.13:8000.

But it doesn't work. I don't even get an HTTP response code: Chrome tells me the response is empty.

1
  • on your other machine, what does ping 192.168.1.13 give? – MattDMo Jun 17 '13 at 17:39
1

Without knowing too much about Mac, if it's anything like Linux it'll be because your server is only listening on the ‘loopback’ interface (lo), which always has the IPv4 addr 127.0.0.1 (and the IPv6 addr ::1), and the domain localhost.

This allows you to run a server on your local machine without it being accessible to any of the networks you are connected to. This has security benefits for certain use-cases.

However, you want it to be accessible from your LAN, so you will need to make sure that your Python script is listening on the interface that has IPv4 addr of 192.168.1.13 in your case.

Turning off firewall and other extra steps may be needed. Once you have it working, you may want to see if it works with the firewall turned back on. If not, you may need to add an exception to your firewall configuration.

2
  • This (+1). And try netstat -a | grep LISTEN to see what's listening where, make sure it's listening on an interface accessible from others on the network. – Rich Homolka Jun 17 '13 at 18:20
  • Thank you! This is excellent advice. Actually, I realised I was running the site on Django's runserver, and this solved my problem: stackoverflow.com/questions/2260727/… – Richard Jun 17 '13 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.