# Solved: Flushing the Cache!



## Chris_E (Feb 16, 2006)

Hello

Would there be any reason why, when using dscacheutil -flushcache in Lion 10.7.3, that IP's are not being refreshed?

I have the iMAC and also have a PC sitting alongside it. The PC sees a website of mine as IP address a.b.c.d. I movedthe site to ab.c.d about 3 weeks ago and the PC is well behaved.

Conversely, the iMAC is still seeing the website at the old IP. Now, from the outside world POV, this is no biggie today but as I develop on the iMAC (not the PC), its a real pain that the Mac isnt seeing the correct OP for the website. So I use the dscacheutil -flushcache command but the Mac still sees the old IP. Grrr.

eg:

>> Ping www.myhost.com
Response : w.x.y.z (when it should be a.b.c.d)
>> dscacheutil -flushcache
Response (still) : w.x.y.z (when it should be a.b.c.d)

Any ideas out there?

Chris


----------



## Headrush (Feb 9, 2005)

Did you run it as root using sudo?


----------



## Chris_E (Feb 16, 2006)

Hi headrush.

Following your email, I tried :

>> sudo -s
Password: {
bash-3.2# dscacheutil -flushcache
bash-3.2# ping www.myweb.com
PING www.www.myweb.com (w.x.y.z): 56 data bytes
64 bytes from w.x.y.z: icmp_seq=0 ttl=116 time=125.264 ms

So, even as root its not clearing the cache.

The Mac has been rebooted prior to this change by the way.

Any further ideas?

Chris


----------



## Headrush (Feb 9, 2005)

Yes, first off it's safer to use sudo this way:

```
sudo dscacheutil - flushecache
```
Try this:

```
sudo killall -HUP mDNSResponder
```
Just so you know what this does, from Apple:


> Mac OS X v10.6 uses the mDNSResponder process for unicast DNS (Domain Name System) functions, as well as Bonjour functions


The command above should force it to restart which will flush it's cache.


----------



## Chris_E (Feb 16, 2006)

Hi



> >> sudo killall -HUP mDNSResponder
> >> ping www.myweb.com
> PING www.myweb.com (w.x.y.z): 56 data bytes
> 64 bytes from w.x.y.z: icmp_seq=0 ttl=116 time=34.013 ms
> ...


An I doing this right I wonder? I fire up Terminal and just type in the sudo..... command?

Erm... no joy?

Chris


----------



## Chris_E (Feb 16, 2006)

Hi all,

Found it! Many months ago, while developing the site I mapped the w.x.y.z IP Address to the hostname in the hosts file. This was of course over-riding all flush attempts!

I found out by looking at the system.log in Console and noted the setting in the /etc/hosts section!

What a dolt!

Thanks for all your inputs which I am sure were totally valid!

Chris


----------



## Headrush (Feb 9, 2005)

Chris_E said:


> Found it! Many months ago, while developing the site I mapped the w.x.y.z IP Address to the hostname in the hosts file. This was of course over-riding all flush attempts!


That was going to be my next question if it didn't work along with making sure your router/modem isn't also caching DNS entries.

Glad you got it working.

*Edit: *Although it couldn't be router/modem if the PC was getting proper IPs.


----------

