I'm in the process of migrating a database server, both the new and the old server are on the same network.

Now I want to test the application that uses this database server on my machine which is also on this network. I don't want to turn the old database server off as its still being used by other people but I would like my machine to think it doesn't exist.

Can I just edit my hosts file to achieve this?

Update : My machine is running Windows 7 and the servers are running Windows Server 2008

Basically I want my machine to think that \\OldServername doesnt exist any more and not be able to access it. This should let me see what problems the application has without having to turn the old server off.

  • what operating system ?
    – Sirex
    Aug 8, 2011 at 13:39
  • Sorry should have said Windows 7 and the servers are 2008
    – Gavin
    Aug 8, 2011 at 13:42
  • you can edit the hosts file to make your machine think the server is unreachable but I'm not sure this is the correct way to achieve this. The hosts file is located in c:\Windows\System32\drivers\etc\hosts
    – Goez
    Aug 8, 2011 at 13:46
  • Why wouldn't you just configure the application to connect to \\newserver?
    – joeqwerty
    Aug 8, 2011 at 19:26
  • I've done just that. Now to test it I want to make sure it can't access the old server
    – Gavin
    Aug 8, 2011 at 20:49

3 Answers 3


Well you don't mention much in the way of details but yes that should work.


Adding this line to my hosts file (c:\Windows\System32\drivers\etc\hosts) seems to solve the problem   sqlServer1

Then to enable the server again just add a # to the beginning of the line

#  sqlServer1
  • This is not really a very good solution, because you're not making it think that the server doesn't exist, you're making it think that the server is the same as your current server. There's an important difference. Aug 12, 2011 at 8:52
  • In this case it does exactly what I needed. If the app tries to connect to the old SQL Server it wont find it and will fail, highlighting any issues. What would you say is the correct solution then?
    – Gavin
    Aug 12, 2011 at 8:55
  • The biggest issue was for example, both servers use an SQL Default Instance, when it goes to connect to the old service, it will find the new one instead, but think it's the old one. The correct solution is to use a firewall to block all traffic to/from the IP address of the remote server. Sorry, if I'd seen this questionback when you asked it, I would have answered as such. Aug 12, 2011 at 9:00

Try to add a false route to this host with this command :

route add mask

( = The Server IP, = An IP that don't exists on your network)

  • The command ran ok but it still seems to find the old server. Does it matter that the application accesses the server by servername rather than IP?
    – Gavin
    Aug 8, 2011 at 14:34
  • 4
    Windows is not going to use the routing table when connecting to the server because the server is on the same subnet, therefore there's no need to query the routing table. Windows is going to ARP for the MAC address of the server.
    – joeqwerty
    Aug 8, 2011 at 15:35

You must log in to answer this question.

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