Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 having a problem serving my django project in a local network. Each project needs a unique domain name in the hosts file. In my local network other computers cannot see the projects.

my computer IP in the network is The hosts file on my computer is like below:      myProject1.local      myProject2.local      myProject3.local

I think I have to make it like this, but it doesn't work.      myProject1.local      myProject2.local      myProject3.local
share|improve this question

migrated from Nov 15 '11 at 11:06

This question came from our site for professional and enthusiast programmers.

Belongs on ServerFault. – Daniel Roseman Nov 14 '11 at 9:31
up vote 2 down vote accepted

Finally I found the solution, It must to setup a DNS server in your local network, if you have any Server Edition OS computer it will be easy to config its DNS server and point it to your projects IP. but when there is no Server Computer in the network (eg: home networks) the problem will be finding a DNS server to curry the responsibility.

I will config Apache on Windows 7 or anything else to handling Django projects with WSGI...

my local IP is and I Bind it with my MAC-ADDRESS in the Router Settings.
NOTICE: be sure to make your IP to be unchangeable, otherwise it will make your DNS Server and local Network unstable.

1. Config Apache to serve multiple Domains:

first step is to config Apache to run the projects:
below will serve myProject1 on www.myproject1.local and myProject2 on www.myproject2.local

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.myProject1.local
    ServerAlias myProject1.local *.myProject1.local 
    DocumentRoot "C:/path/to/myProject1/"

<VirtualHost *:80>
    ServerName www.myProject2.local
    ServerAlias myProject2.local *.myProject2.local 
    DocumentRoot "C:/another/path/to/myProject2/"


for more informations visit : [Apache Name-based Virtual Host Support]

2. Lunch Django Projects with WSGI:

if you want to serve a PHP project its works, but to config WSGI you have to make a little changes like below. I treat project1 to be django project

<VirtualHost *:80>
    ServerName www.myProject1.local
    ServerAlias myProject1.local *.myProject1.local 
    #WSGIDaemonProcess myProject1 processes=2 threads=15 display-name=%{GROUP}
    #WSGIProcessGroup  myProject1
    WSGIScriptAlias / "C:/path/to/myProject1/myproject1.wsgi"


Be sure to load : []

commented lines WSGIDaemonProcess and WSGIProcessGroup are options to perform better WSGI service for more informations visit : [mod_wsgi Wiki Pages]

3. Installing a DNS Server

now you must config your dns server. in my case I have no dns server installed on my computer so first step is to find proper dns server to do the job.
I Use [MaraDNS], and config it like below:

mararc file

ipv4_bind_addresses             = ""
timestamp_type                  = 2
random_seed_file                = "secret.txt"
hide_disclaimer                 = "YES"
csv2                            = {}
csv2["myproject1.local."]       = "db.default.txt"
csv2["myproject2.local."]       = "db.default.txt"
upstream_servers                = {}
upstream_servers["."]           = "yyy.yyy.yyy.yyy, zzz.zzz.zzz.zzz"

and the db.default.txt file like below

%  ~
www.% ~

for more information about maraDNS visit MaraDNS Website

4. Lunching DNS Server:

Lunch maraDNS Server by

maradns -f mararc

5. Router Settings :

you could access your domains by setting primary DNS server to point to for each computer in your local network. but you also could set the Router DHCP server to use your IP as the default DNS Server. it just need access to the Router web-Administration.
so enter your IP there as DNS Server and the job is done.

6. Enjoy the Trick:

now you can to serve your projects in local network as faked domains without using :port-number or IP addresses. just enter myproject1.local in address-bar of any of your local network computer or WiFi devices and get the right result.

share|improve this answer

What you are attempting to do is set multiple ip-addresses on the same host, not domain names. There are several problems with what you are trying to do: First you seem to set the hosts file only on the machine the server application is running on, which means that no other machine in the network will know about them.

Another problem is that to set multiple ip-addresses on the same host you have to do it in your network config, and how to do it differs depending on the operating system you are using.

The third thing is that you don't need one ip-address per host. One ip-address can have many hostnames. This is either set up in a name server, or if you don't have it for the local network, you can use aliases in the hosts file:   hostname1 hostname2 hostname3

Then in Apache (or whatever web-server you use) you use name-based virtual hosts.

And last a note about your current setup with using ip-addresses in the 127.x.x.x range, these are always considered local to the host, so trying to connect another computer through that address range will never work.

share|improve this answer
thanks for response, but i have to explicitly use fake domain names (eg: fakedomain.local) instead of IP addresses, so how can I setup my Win7 and ADSL-Router to get that result? – wtayyeb Nov 14 '11 at 9:39
@wtayyeb Use the hosts-file, like in my example, and put the same line in all hosts files on all computers in the network. In my example, the same ip-address can be reached by using three different hostnames. – Joachim Pileborg Nov 14 '11 at 9:45
but i still have problem with multiple django projects, there is only one port 80 for each IP so only one project at once can be lunched, and noo way remains just using :port_number after domain, and it is not good. – wtayyeb Nov 14 '11 at 14:23

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.