How do I configure the ip address with CherryPy?

Matt Price picture Matt Price · Sep 22, 2008 · Viewed 23.1k times · Source

I'm using python and CherryPy to create a simple internal website that about 2 people use. I use the built in webserver with CherryPy.quickstart and never messed with the config files. I recently changed machines so I installed the latest Python and cherrypy and when I run the site I can access it from localhost:8080 but not through the IP or the windows machine name. It could be a machine configuration difference or a newer version of CherryPy or Python. Any ideas how I can bind to the correct IP address?

Edit: to make it clear, I currently don't have a config file at all.

Answer

fumanchu picture fumanchu · Sep 30, 2008
server.socket_host: '0.0.0.0'

...would also work. That's IPv4 INADDR_ANY, which means, "listen on all interfaces".

In a config file, the syntax is:

[global]
server.socket_host: '0.0.0.0'

In code:

cherrypy.server.socket_host = '0.0.0.0'