Cherrypy server is inaccessible from anything other than localhost

I have an issue with cherrypy that looks drastic but doesn't work. I can only bind to localhost or 127.0.0.1. Windows XP Home and Mac OS X (linux untested), cherrypy 3.1.2, python 2.5.4. This is the end of my application:

global_conf = {
       'global':    { 'server.environment= "production"'
                      'engine.autoreload_on : True'
                      'engine.autoreload_frequency = 5 '
                      'server.socket_host': '0.0.0.0',
                      'server.socket_port': 8080}
    }
cherrypy.config.update(global_conf)
cherrypy.tree.mount(home, '/', config = application_conf)
cherrypy.engine.start()

      

+2


source to share


2 answers


Yes, you are doing something wrong with your dict:

>>> global_conf = {
...        'global':    { 'server.environment= "production"'
...                       'engine.autoreload_on : True'
...                       'engine.autoreload_frequency = 5 '
...                       'server.socket_host': '0.0.0.0',
...                       'server.socket_port': 8080}
...     }
>>> print global_conf
{'global': 
   {'server.environment= "production"engine.autoreload_on : Trueengine.autoreload_frequency = 5 server.socket_host': '0.0.0.0',
    'server.socket_port': 8080}
}

      

In particular, your dict definiton is missing commas and colons. Each key / value pair must have a colon and are separated by commas. Perhaps something like this:



global_conf = {
       'global':    { 'server.environment': 'production',
                      'engine.autoreload_on': True,
                      'engine.autoreload_frequency': 5,
                      'server.socket_host': '0.0.0.0',
                      'server.socket_port': 8080,
                    }
              }

      

Read more on the python dictionary documentation .

+6


source


If you are using a two-tier OS, it may be that localhost allows :: 1 (IPv6 localhost) and not 127.0.0.1 (IPv4 localhost). Try to access the server using http://127.0.0.1:8080 .



Also, if you are using a dual-stack compatible OS, you can set server.socket_host to '::' and it will listen on all addresses in IPv6 and IPv4.

+3


source







All Articles