We have several web applications running on several load-balanced servers. We want to have our web applications communicate with each other without first traversing outside the load balancer.

For example:

  • http://appA.example.com is running on and
  • http://appB.example.com is also running on and
  • The load balancer's public IP address is
  • By default, when appA on makes a call to a WCF service hosted in appB, the HTTP request is routed to; this establishes a new session and the load balancer will direct the call to either of the two servers
  • We want the call to be routed to the instance of appB running on the same server so we add appB.example.com to the hosts file on

This eventually works, but we either have to wait for the app pool to naturally recycle or do a manual reset before appA sees the new address.

Is there any way to have the change automatically detected without having to recycle the app pool?


At Safeco, we used a DNS server for this purpose.. we made CNAME aliases.. all stored in one place.. when we made a change like this, it started working immediately. DNS server is basically like a hosts file, but a lot more capable.

  • a bit overkill for general use, but still a good answer
    – PatomaS
    Oct 22 '12 at 6:30
  • This doesn't quite work for me. I have two servers hosting the same two apps. The reason for using the hosts file is because I want the primary app on each server to use the secondary app on the same server. In order to use DNS, I'd have to have one entry for each server and reconfigure the two primary apps to use the right name. That's problematic for other configuration management reasons. Oct 28 '12 at 13:29
  • no.. changing to FQDN for everything makes it easier.. because then you can change it in one place (for all connection strings) instead of changing connection strings in 10 different places. It's genius. SqlApp1.corpname.com can point to one machine and SqlApp2.corpname.com can point to secondary machine. If you want to swap them, you can swap them, no problem. DNS is easier, you change things in one place, instead of HOSTS file on two servers. Oct 28 '12 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.