22

I've created a Python web app using CherryPy, and have deployed in on my local machine.

When I try to view it from another computer in the house, nothing comes back.

However, if I create a simple html file, and deploy it with:

$ python -m SimpleHTTPServer

It is visible over the intranet.

I'm stumped as to why my app could work locally, but not be avalable over the intranet, given that there is not a connection problem between these machines, and that I can serve other content on the same port.

I have not used a configuration file, I'm using the default CherryPy settings.

Eric Wilson
  • 57,719
  • 77
  • 200
  • 270

1 Answers1

32

The default settings likely bind to localhost, which is not publicly available. If you want CherryPy to run on a public interface, you'll have to direct it to do that. From this discussion I found:

cherrypy.config.update(
    {'server.socket_host': '10.149.4.240' } ) # Pub IP
cherrypy.quickstart()

or

cherrypy.config.update(
    {'server.socket_host': '0.0.0.0'} )      
cherrypy.quickstart()

To bind to all interfaces.

Gringo Suave
  • 29,931
  • 6
  • 88
  • 75
  • 2
    You should be fine with 0.0.0.0. That is basically your local computer, publicly accessible (while the default 127.0.0.1 is your local computer, not publicly accessible). – Dave Sep 21 '11 at 08:30
  • 4
    To clarify this answer, one way to configure the socket host is to call `cherrypy.config.update({'server.socket_host': '0.0.0.0'})` before calling `cherrypy.quickstart()`. A config file could also be used. – Eric Wilson Sep 21 '11 at 12:33