Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am learning Django and wanted to test hosting it on an Ubuntu computer I have. I decided to serve it with Apache and mod_wsgi. I got most things working, but I have one thing puzzling me. I can access the website only from my external IP address, not from say or my 192.168.x.x address.

My django.conf file in /etc/apache2/sites-available is

<VirtualHost *:80>

WSGIScriptAlias / /home/username/project

ServerName my_external_ip

Alias /media/ /home/username/project/media
Alias /static/ /home/username/project/static

<Directory /home/username/project>
Order allow,deny
Allow from all


If I set ServerName to then the page only loads from there. Also I should add, it doesn't exactly "not load" when I access from other locations, it just shows an Apache page titled "Index of /" with no contents.

What is stopping Apache serving pages in all cases, and how can I make it serve pages as etc..? Is there a better way I should host it?

share|improve this question
up vote 1 down vote accepted

Your answer lies in apache2ctl -S - the "default" site from the install takes precedence when the Host header that the HTTP client sends doesn't match a ServerName or ServerAlias in one of the other <VirtualHost> blocks on the port.

If you want your Django site to be handling all requests to the server, then disable the default:

a2dissite default

...then restart Apache.

Otherwise, if you want to be a little more nuanced about having Django take over, you can add a ServerAlias to the config of its <VirtualHost>:

ServerAlias internal.ip external.ip
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.