View website across local network?

1

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.

Richard

Posted 2013-06-17T17:22:26.813

Reputation: 153

on your other machine, what does ping 192.168.1.13 give? – MattDMo – 2013-06-17T17:39:26.003

Answers

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.

James Haigh

Posted 2013-06-17T17:22:26.813

Reputation: 554

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 – 2013-06-17T18:20:33.953

Thank you! This is excellent advice. Actually, I realised I was running the site on Django's runserver, and this solved my problem: http://stackoverflow.com/questions/2260727/accessing-local-django-webserver-from-outside-world

– Richard – 2013-06-17T18:34:18.250