- What is a hostname?
- How the hosts file works
- Editing the hosts file
- Using the hosts file
The hosts file is an operating system file located on your computer. You can use the hosts file to redirect a hostname to an IP address. This allows you to use the same hostname in different locations, and map that hostname to different IP addresses.
Note: If you prefer you can also store the IP address in an external file — using a configuration variable like “HL7_DB_IP” or “jupiter_IP”.
This has the advantage of one less dependency (you don’t need to edit the hosts file). But your Administrators may prefer to use the hosts file (if they are used to it). In the end it your choice.
Tip: It is possible to use a local DNS server for these redirections (instead of the hosts file). But that is beyond the scope of this article.
You can discuss this with your Network Administrator who may prefer to use DNS.
What is a hostname? [top]
A hostname is basically a label (name) for a device on a computer network (like a computer, a database server, or an Iguana server). A hostname can be a single unqualified name like Jupiter or longer “qualified” name like jupiter.example.net. In general we recommend using the qualified name whenever possible.
With the internet we are very used to using these longer qualified Domain names as part of the URLs http://jupiter.example.net that we use in our web browsers (like Chrome and FireFox). Notice that the “http://” is not part of the hostname — the hostname is simply “jupiter.example.net”.
Editing the hosts file [top]
First you need to locate the hosts file on your system. These are the most common locations:
- Windows: c:\windows\system32\drivers\etc\hosts
- Linux, Unix, Posix: /etc/hosts
- Mac: /etc/hosts (a symbolic link to /private/etc/hosts)
Otherwise you can search for the filename “hosts”. And the Wikipedia hosts file page also has a section Location in the file system that is helpful.
Because it is an operating file you will need administrative access to edit it. In Windows you can right-click on notepad and choose to run it as administrator. In Linux, Unix and Mac the easiest way is probably to use sudo to run a text editor from terminal.
Using the host file [top]
You will need to add entries to the hosts file for each Iguana Server environment. For example if you have three Iguana environments Dev, Test and Prod you will need to edit the hosts file on all three servers.
The hosts files entries use this general format:
For example to redirect the jupiter server:
So lets use our example where we have three Iguana Environments Dev, Test and Prod that use a database HL7_DB.foxton.com. The Dev and test environments use the same DB 188.8.131.52 whereas the production server uses 184.108.40.206.
These are the entries you will need to add to the hosts file on each Iguana Server:
- Iguana Dev server:
- iguana Test server:
- Iguana Prod server:
Note: You could use an entry with unqualified server name, like this:
But we recommend using a qualified name if possible.