1

I would like to access my CherryPy site on a different computer, but I have tried the answers form here and here, but neither have worked. I am using a Mac with OSX El Capitan, Python 3.5.2, and I believe, the latest version of CherryPy. This is my current code, I do not care what the address is, just that it works. Thanks for any help!

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

# bind to all IPv4 interfaces
cherrypy.config.update({'server.socket_host': '0.0.0.0'})
cherrypy.quickstart(HelloWorld())

EDIT:

I can access the site from localhost:8080 127.0.0.1 and 0.0.0.0. The console output is this:

[26/Jul/2016:19:10:26] ENGINE Listening for SIGTERM.
[26/Jul/2016:19:10:26] ENGINE Listening for SIGHUP.
[26/Jul/2016:19:10:26] ENGINE Listening for SIGUSR1.
[26/Jul/2016:19:10:27] ENGINE Bus STARTING

Warning (from warnings module):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/cherrypy/_cpchecker.py", line 105
    warnings.warn(msg)
UserWarning: The Application mounted at '' has an empty config.
[26/Jul/2016:19:10:27] ENGINE Started monitor thread '_TimeoutMonitor'.
[26/Jul/2016:19:10:27] ENGINE Started monitor thread 'Autoreloader'.
[26/Jul/2016:19:10:27] ENGINE Serving on http://0.0.0.0:8080
[26/Jul/2016:19:10:27] ENGINE Bus STARTED

I run my file using IDLE, and I am not using a firewall.

Community
  • 1
  • 1
nedla2004
  • 1,115
  • 3
  • 14
  • 29
  • 1) Is it available from localhost? 2) Does it really bind to some TCP port? What is the console output? 3) Do you have any firewall set up for your Mac? 4) How do you try to access the app? – webknjaz -- Слава Україні Jul 26 '16 at 20:07
  • You've mentioned all that you tried except the IP address from the other computer – OneCricketeer Jul 26 '16 at 23:28
  • @webKnjaZ I tried to edit my question to address your questions. I am not sure what TCP ports are, or if is binding to one, could you explain? – nedla2004 Jul 26 '16 at 23:32
  • @cricket_007 I have tried to do that, sorry for not saying that in my question. I am not sure I got the IP address correct, how should I have gotten it? – nedla2004 Jul 26 '16 at 23:35
  • Open terminal in mac. Run `ifconfig`, you may see the IP of `inet 192.168.1.x`, for example. You need to use that when connecting from another computer. Also, Mac does have a firewall, and I suggest you leave it running – OneCricketeer Jul 26 '16 at 23:36
  • @cricket_007 would that be just after `inet`? – nedla2004 Jul 26 '16 at 23:38
  • I think? For example `127.0.0.1` is your loopback address. `192.168.1.x` is the LAN address. – OneCricketeer Jul 26 '16 at 23:39
  • My site appeared on a different device, thank you so much! Is this only for LAN? – nedla2004 Jul 26 '16 at 23:44
  • As long as both computers are on the same network your app should be reachable. So it's a networking question. Make sure you properly understand how computers communicate on LAN and you'll understand the rest :) To access the app from another LAN you'll have to configure your router, since local addresses are usually masked for guys outside. – webknjaz -- Слава Україні Jul 27 '16 at 10:07

1 Answers1

2

The solution is mentioned in comments below the question so this answer is just for marking this question as answered.

Solution: If you want to see your cherrypy application from another computer, find out an IP address on computer where cherrypy is running, using ifconfig on Unix/Linux or ipconfig on Windows. Then set this IP address to your cherrypy config instead of 127.0.0.1 or 0.0.0.0.

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

As long as you're on the same network, you should be able to access the application on that IP/port that you set: http://192.168.1.123:8080/ (or similar)

If you need to change IP and port, use this:

cherrypy.config.update({
    'server.socket_host' : '127.0.0.1',
    'server.socket_port' : 9090,
})
dwich
  • 1,710
  • 1
  • 15
  • 20