Super User is a question and answer site for computer enthusiasts and power users. 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'm testing an application on my PC, this application connects to various servers so I need to mimic that on my box.

How can I map hostnames to

localhost already refers to, but how could I add more such as server-1 and server-2 to

I'm on Windows 7.


share|improve this question
Use different port numbers like localhost:1111 , localhost:2222 – Shekhar Feb 24 '11 at 10:10
I want to use different hostnames not different ports – user155695 Feb 24 '11 at 10:11
up vote 10 down vote accepted

Just edit your hosts file and use that to point to or the local IP address of your machine.

The file is normally in: /windows/system32/drivers/etc

eg - here's mine and I have been testing a few 'servers' as you can see:

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#          # source server
#              # x client host

# localhost name resolution is handled within DNS itself.
#       localhost
#   ::1             localhost  feng helpdesk wiki rs precurio zendto
share|improve this answer
You can put multiple hostnames in a single address line. – grawity Feb 24 '11 at 11:08
True - I put them on separate lines as its quick and easy to comment them in and out as needed. – Linker3000 Feb 24 '11 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .