Reputation: 1
I am experiencing problems with visibility / accessibility of my python web server running on Ubuntu. Server code is below:
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8899
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("Hello World !")
return
try:
#Create a web server and define the handler to manage the
#incoming request
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
#Wait forever for incoming htto requests
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
Calling it locally using curl with below command works - I receive answer with 'hello world'.
curl {externalIP}:8899
Opening address in the browser (chrome, ie) fails!
http://{externalIP}:8899/
ufw status is inactive
iptables as below
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:8765
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Ubuntu has apache2 server installed and opening html files using web browser, external ip and port 80 is working with no problem from above server...
Any ideas what else could I check?
Upvotes: 0
Views: 1829
Reputation: 1
Removing apache fixed this case. I do not know why, because it should block port 80, but it works now after this:
apt-get remove apache2*
Upvotes: 0
Reputation: 74
I think you might be listening on the loopback interface and not the one that is connected to the internet.
Either specify IP or use:
server = HTTPServer(('0.0.0.0', PORT_NUMBER), myHandler)
to specify to listen to all your network interfaces.
Upvotes: 1