Python (CherryPy) web app deployed locally, but not visible over intranet
Asked Answered
C

1

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.

Carlinecarling answered 21/9, 2011 at 3:11 Comment(0)
C
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.

Canst answered 21/9, 2011 at 4:48 Comment(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).Chapeau
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.Carlinecarling

© 2022 - 2024 — McMap. All rights reserved.