Kumakaja Kumakaja - 1 year ago 104
HTTP Question

BaseHTTPServer.HTTPServer isn't visible from the Internet

I'm running a Python server on a remote server:

server_class = BaseHTTPServer.HTTPServer
httpd = server_class(("", 80), MyHandler)

From a server, I can make a query: "curl -i localhost" and it works fine. However, from a remote computer I can't, even though there's no firewall.

curl: (7) Failed to connect to aa.bb.cc.dd port 80: Connection refused

I'm trying to do that by the ip address of a server.

Answer Source

Of course you cannot. You bind you server to the local only address, so it can only answer local queries. Use the special address to allow it to answer on any interfaces:

httpd = server_class(("", 80), MyHandler)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download