# How to turn off DNS caching

**URL:** <https://www.ruby-forum.com/t/how-to-turn-off-dns-caching/244568>\
**Category:** NGINX\
**Created:** [May 4, 2016, 1:12pm UTC](https://www.ruby-forum.com/t/how-to-turn-off-dns-caching/244568 "2016-05-04T13:12:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [May 4, 2016, 1:12pm UTC](https://www.ruby-forum.com/t/how-to-turn-off-dns-caching/244568/1 "2016-05-04T13:12:32Z")

</div>

Hi,

I am trying to connect to my AWS RDS (mysql) instance using the AWS  
supplied  
DNS endpoint.

The problem is, the IP of the instance changes periodically.

It appears that nginx does not resolve the DNS name every time, but  
caches  
it.

Therefore nginx initially works, then at some point later, things break.

How can I turn off the DNS caching?

Posted at Nginx Forum:

> **[How to turn off DNS caching](https://forum.nginx.org/read.php?2,266604,266604#msg-266604)**
>
> Hi, I am trying to connect to my AWS RDS (mysql) instance using the AWS supplied DNS endpoint. The problem is, the IP of the instance changes periodically. It appears that nginx does not resolve the DNS name every time, but caches it. Ther

---

<div class="post-metadata">

**Author:** ![Sem9999](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de053/32.png) [@Sem9999](https://www.ruby-forum.com/u/Sem9999)\
**Post date:** [May 4, 2016, 1:48pm UTC](https://www.ruby-forum.com/t/how-to-turn-off-dns-caching/244568/2 "2016-05-04T13:48:46Z")

</div>

Hello,

On May 4, 2016, at 7:12 AM, Sem9999 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Therefore nginx initially works, then at some point later, things break.
> 
> How can I turn off the DNS caching?

Add a “valid” parameter to your resolver directive:

resolver 127.0.0.1 valid=5s;

This would set it to cache 5s.

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver)**
>
> This directive appeared in version 1.11.8.
