Ubuntu – Accessing port 8000 on ubuntu in vmware fusion

networkingpythonUbuntuvirtualization

Disclosure: on the server, I am a nooooob. There I said it.

so I have a vm running ubuntu with a BRIDGED network connection and running a python web-server on port 8000. When I go to http://localhost:8000/ inside the vm, all is working as expected. But I need to access this web-server from outside the vm on the same machine. I used ifconfig to get the local network ip 192.168.1.131 of the ubuntu vm. Now if I visit http://192.168.1.131 in my browser outside the vm I get a page stating:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

However this is not my python web-server, its something else running on port 80. My python is running in port 8000, and when I got to http://192.168.1.131:8000 I get:

Unable to connect

      Firefox can't establish a connection to the server at 192.168.1.131:8000.

What is going on here? Could ubuntu be blocking incoming connection in 8000 but allowing them on 80? This is a fresh install on the vm of Ubuntu 12.04 LTS 64 bit. Any help is appricated. Thanks.

Best Answer

Your Python web server can choose which address(es) it listens to. It might be listening only on the localhost address (127.0.0.1) and not on the external IP address 192.168.1.131. On the other hand, Apache (or whatever is responding on port 80) is probably listening on all addresses, including both localhost and your external IP address.

To do this with Django, try using:

runserver 0.0.0.0:8000

See the documentation for django-admin for further details.