Select Page

Using a Local Domain Name for Testing

Using a Local Domain Name for Testing


If “Money Makes The World Go Round” then Domain Names make the Web go round.  Without them we would all have to remember ip addresses (or yes – use a search engine).

Remembering instead of may be do-able, but try adding for and instead of to the old grey matter and you’ll soon have trouble.  And that’s before any ip address changes.

So – we’re all agreed – domain names are a jolly good idea – and for the most part not that expensive.  £10-£15 will get you a domain name for a year.  But what if you don’t want to buy a domain name because you’re just testing or learning – well the good news is you don’t have to buy a domain name to use one.

You can make up your own domain names and not spend a penny by using a local domain name.  The only downside is it will only work on the computer you set it up on.  But for testing or learning something that’s fine.

1. The Host File

So – how does it work?  Well, whether you’re using Linux or Windows or OSX they all have one thing in common.  They all have a host file.

This host file holds domain names and ip addresses and allows you to add domain names to your local device for testing.

The host files follow a pretty standard format which ever operating system they’re on – which is lucky for us.

Here’s an example of the default (unaltered) host file from a Windows 10 PC.


and here’s one from Linux.


and from OSX.


You should be able to see the similarities between the three above.

One thing to remember is that the host file is checked BEFORE the internet for a domain name match.

In this way you could send your browser to a different site so when you enter it goes to your test server.  Not really a great idea, just know your host file is checked first.

2. Editing a Windows Host File

You can use any editor to edit the Windows host file.  As it’s a simple text file Notepad is a great choice.

Find Notepad in your menu and right click to bring up the context menu.


Select Run As Administrator and click YES  to “allow app to make changes”.

Select File->Open  from the Notepad menu and browse to c:\windows\system32\drivers\etc


Select All Files as above and then double click on ‘hosts’.


Now jump to the section lower down – Adding Your Own Local Domain Name.

3. Editing a Linux Host File

As with the Windows host file, the Linux host file is plain text so can be edited with your favourite editor such as Nano or Vi

To use Nano

> sudo nano /etc/hosts

To use Vi

> sudo vi /etc/hosts


Now jump to the section lower down – Adding Your Own Local Domain Name.

4. Adding Your Own Local Domain

With your editor open, go to the last line and make a new line.

The IP address is first things on the line and then the domain name so type the following on a new line:

where is the ip address of your test website and is the name you want to use.

You can have multiple names on one line such as :

Now save the file.

You should now be able to browse to your test website, but remember – only from the computer where the edited host file is saved.

Leave a reply