Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have nginx redirect like:

server {                                                                                                         
      server_name  myname.local
      location / {                                                                                               
          proxy_pass http://m1.local:8080;                                                               

Works good.

But after ip address for m1.local was changed - nginx start to return "bad gateway".

Looks like it has caching ip address for m1.local.

nslookup m1.local from nginx computer show right value, and restart nginx repair the situation.

How to say nginx that it shouldn't cache ip's for dns name?

share|improve this question

Nginx is doing these name lookups on start, and then it only keeps the IPs. This means that it won't even keep the names in memory during run time to look them up again.

If you change the DNS entries that you refer to in the Nginx conf, you can do an nginx -s reload to make it reload the config, this includes redoing the DNS lookups.

share|improve this answer
Yep. I sure you right, but it is not helps. This ip changed not by me, by another proccess, so I never know when do "reload". – Korjavin Ivan Sep 5 '13 at 12:03
up vote 1 down vote accepted

I found solution here:,238835,238899#msg-238899

location / {
set $backend "m1.local";
proxy_pass http://$backend;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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