Bruce
Bruce

Reputation: 955

Can't connect to local web server from Android device

I've connected my Android phone to my laptop using Connectify.

I have a cherrypy web server running on 192.168.210.1:8080:

import cherrypy

class HelloWorld:
    def index(self):
        return "Hello world!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

It works on my laptop, but when I try to put 192.168.1.8080 in my Android, there's no response and it keeps waiting indefinitely. I tried pinging to the IP from my phone, and it works, showing replies.

I also tried turning Windows Firewall off - it instanantly results in the message "Oops! Google Chrome could not connect to 192.168.210.1:8080". If I start it again, it's back to the previous state.

Please help.

Upvotes: 0

Views: 1188

Answers (1)

cyraxjoe
cyraxjoe

Reputation: 5741

You need to bind the socket on which the server is listen to '0.0.0.0', by default is bound to localhost, to do that just change the quickstart call, with this config:

config = {'global': 
            {'server.socket_host': '0.0.0.0'}
}
quickstart(HelloWorld(), config=config)

Upvotes: 1

Related Questions