durusmail: quixote-users: simple_server: can only connect from localhost
simple_server: can only connect from localhost
2005-03-10
2005-03-10
2005-03-10
simple_server: can only connect from localhost
mso@oz.net
2005-03-10
Peter Fein wrote:
> I'm using simple_server.py for my development work because I'm lazy and
> my employer hasn't decided on a real webserver yet.  I find I'm only
> able to connect from that machine (ie, localhost) and not from others on
> its subnet (no firewall issues I can think of).
>
> nmap on the local box shows 8080 open, but not when run from another
> machine.  Any thoughts?

That happened to me too, and it's a quirk in the socket library.  A host
argument of '' means listen on all interfaces; otherwise it listens only
on the specified IP.  If you copied the code from the Quixote demo as I
did, it only listens on the localhost:

    from quixote.server.simple_server import run
    run(create_publisher, host='localhost', port=8080)

So use host='' instead.

quixote.server.util.main() also defaults to 'localhost'.

I haven't used nmap, but netstat tells what addresses a socket is
listening on:

$ netstat --inet -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address      State
tcp        0      0 *:www                   *:*                  LISTEN
tcp        0      0 localhost:33161         localhost:www        ESTABLISHED

The first line means my webserver is listening on all addresses.  The
second line means I have "telnet localhost 80" running in another window.


reply