Sign up ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

How can I clear my DNS cache on my android phone? (Droid3, Gingerbread, rooted to be specific)

Ideally I'm looking for a command to run through a terminal emulator, something similar to

ipconfig /flushdns

On a windows machine.

What's the Linux version of this?

share|improve this question
Do you need to do this for a system app, third party app or your app? – onik Sep 1 '11 at 4:02
Third party I guess? I need it for when I ping a server via Terminal Emulator. – Steve Robbins Sep 1 '11 at 4:30
Please update your title to reflect that you want a CLI-based answer. This is ranking in Google and 99% of people searching this title do not have root or CLI skills. – PJ Brunet Aug 11 at 16:09

4 Answers 4

up vote 9 down vote accepted

On a typical Linux system the cache is cleared by running /etc/init.d/nscd restart, but at least my ROM doesn't use nscd to cache DNS. You can check if yours does, but I doubt it. I've seen suggestions that clearing the brower cache would clear DNS cache too, but one sure way is to do a hard reboot (shutdown, remove battery for 30s, reattach battery and boot).

share|improve this answer
All of my googling also brings up the "hard reboot" suggestion. – Chahk Sep 1 '11 at 14:03
I'm downvoting because the answer requires root and/or assumes shell access which is unrealistic for most Android users. The rest of the answer did not solve my problem. Also I believe Matthew Read should reconsider locking the question because this is absolutely not a "done deal." DNS is extremely complex and there will be more legitimate answers from people without Android accounts here yet, I'm an example of that. FWIW I do have 10+ reputation and still could not answer the question. – PJ Brunet Aug 11 at 15:51
@PJBrunet To be accurate, you have 1 rep and 100 rep from association bonus, which does not count since you haven't earned it on this site. See What is a "protected" question? for more details. As for the question, I'll unprotect it for now. – onik Aug 11 at 15:54

The only way to do this in Android is to do a hard reboot. The necessary command-line tools are not normally available, however in my tests a hard reboot has always done the trick for me (Galaxy Nexus, and HTC Desire, various ROMs).

This is a pain, but it is quicker than the 10min cache timeout.

share|improve this answer
How does one perform this? – Steve Robbins Nov 29 '11 at 5:20
- Hold down the power button - Choose "Power off" - Allow phone to fully shut down - Remove battery and wait 30s - Return battery - Power phone back on. In my experience removing the battery is not necessary, but some have reported it doesn't work if you miss this step. – Martin Nov 29 '11 at 8:27

Addresses are cached for 600 seconds (10 minutes) by default. Failed lookups are cached for 10 seconds. From everything I've seen, there's nothing built in to flush the cache. This is apparently a reported bug in Android because of the way it stores DNS cache. Clearing the browser cache doesn't touch the DNS, the "hard reset" clears it because it simply times out.

Can we ask the underlying reason for needing to clear the DNS cache? Perhaps there's another solution that's missed because we're not looking at the bigger picture.

share|improve this answer
Not sure about the OP, but I have a use case where my home network serves addresses like, but my ISP resolves * (for any value of "*" this is not already mapped) to if my phone is on 3G/4G, so I'm sometimes unable to access my home network until the cache times out. – TomG Aug 25 '12 at 1:25
Looks like the forced 10-minute caching is fixed in JB — see this commit. For older releases the Java cache behavior could be tuned by networkaddress.cache.ttl and networkaddress.cache.negative.ttl in build.prop. – Sergey Vlasov Jun 2 '13 at 18:19
Fwiw, there are still some (perhaps different) DNS issues even in 4.3 - tablets on wifi may not get an IP address for names that Linux and Windows machines (on the network that hosts the wifi) can resolve. – Jon Shemitz Feb 25 '14 at 21:50

There're also apps like Internet Booster promising to "clear DNS cache" (amongst other things). I didn't try it out myself, and furthermore there seems no way to do only that (just one "optimize" button which "applies improvements"); also its effects might differ between devices (says the app's description) -- but it might be better than a reboot. Btw: while not mentioning root as requirement, it might still be needed.

There are several "similar apps" listed on Google Play -- but be aware that most of them include Airpush ads and/or want excessive permissions, which is why I didn't name them here.

Another possible solution (not tested by myself) I found at MadPC, seemingly quoting user8522's answer before stating:

The last option but most intensive on the user themselves unless they want to just wait the update out: Have your users go into settings -> applications -> Network Location -> Clear data

Another short howto mentions a different easy way to flush DNS (again, I didn't test this myself): Simply switch to airplane mode (oops, no network?) and back (ah, there it is) should do the trick. Might sound stupid, but I could imagine when entering airplane mode Android does something similar to /etc/init.d/networking stop, which has a DNS flush as side-effect.

A very easy solution was supplied by dtumaykin in the comments below: simply switching to airplane-mode and back might already do it (of course with the side-effect of the network going down for a couple of seconds ;) Though it might not work on some devices, it's worth a try: no extra installs, and easily performed even by n00bs.

If anybody tried one of those solutions, confirmation (or the opposite) is surely welcome :)

share|improve this answer
There are shell commands ndc resolver flushdefaultif and ndc resolver flushif wlan0; they require root. There is also NetworkManagementService.flushDefaultDnsCache() method, which required just CHANGE_NETWORK_STATE before JB, but then was locked down to CONNECTIVITY_INTERNAL. So there apparently was a hackish way to clean DNS cache without root (after build.prop tuning to kill the Java-level cache), but it will not work in JB. – Sergey Vlasov Jun 2 '13 at 19:20
Thanks for the additional information, @SergeyVlasov ! Do you know if any of the methods you mentioned gets triggered by the two proposed solutions mentioned last in my answer (or if they do work, but for a different reason)? – Izzy Jun 2 '13 at 19:37
Airplane mode on-off worked out for me. Samsung Galaxy S4 Mini and CM12.1. – dtumaykin Jul 4 at 12:45
I can't answer because Matthew Read locked the question. Please slap him for me :-) Hard reboot did not work for me, airplane mode did not work, clearing "location" (as per answer) did not work, waiting hours did not work either. In the past, I've simply solved this by closing the browser tab and opening a new tab. There is a "no root" app (Google DNS) however, I can't grant VPN access because I already have a VPN app that I paid for. The solution for me was change the VPN's "virtual location" setting or the solution was to stop & start my VPN. Assuming my VPN has its own DNS cache. – PJ Brunet Aug 9 at 21:20
@PJBrunet I won't slap a mod (too dangerous, he might close my account ;) and besides, my arms are not long enough to reach oversea). But gaining 10 rep isn't too hard (ask a good question getting 2 upvotes, or write an answer getting 1 upvote); with that, come back here and write your answer :) Thanks for sharing! – Izzy Aug 10 at 8:43

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.