Your computer and browser temporarily cache DNS query results (domain name → IP address) to speed up browsing. After changing DNS records — for example an IP change, migration, or editing an A/CNAME record — your machine may still use an older cached value. This guide explains, step by step, how to flush that cache on Windows, macOS and Linux, how to verify resolution, and what to do if you still reach the old server.
Practical reference: How to Clear Your DNS Cache — cPanel Documentation. For technical background, see also Domain Name System (Wikipedia) and DNS over HTTPS (DoH) — Wikipedia.
Before you begin — quick prerequisites
- Administrator access (Windows) or sudo privileges (macOS / Linux).
- The domain name in question and, if possible, the expected IP address after the change.
- Close or clear the browser cache after running the command (browsers also keep a DNS cache).
- If you modified the DNS zone through your hosting provider, first check the DNS zone (zone editor). See our internal guide Manage the DNS zone.
Useful reminders
- Flushing the local cache only affects your device: resolvers (ISP, public resolvers) can still return the old value until the record's TTL expires.
- Common public resolvers: 1.1.1.1 (Cloudflare), 8.8.8.8 (Google) — you can query either to compare responses.
- If you plan a migration, reduce the TTL several hours/days before the change to speed up propagation.
- If you use DNS-over-HTTPS (DoH) in your browser, the browser may keep application-side resolutions — also clear its cache or test in private/incognito mode.
Procedure: by operating system
Windows 10 / 11 / Server
- Open the Command Prompt (CMD) or PowerShell as administrator (right-click → 'Run as administrator').
- Run:
You should see a message confirming that the DNS cache has been flushed.ipconfig /flushdns - To view the current cache (for diagnostic purposes):
ipconfig /displaydns - If the problem persists (network errors, erratic DNS resolution), try:
Then restart the computer. This command resets the WinSock layer — useful for some socket-related network issues.netsh winsock reset
macOS (Terminal)
Open Terminal (Applications → Utilities → Terminal). On most recent versions, run:
sudo killall -HUP mDNSResponder
sudo killall mDNSResponderHelper
sudo dscacheutil -flushcache
You will need to enter the administrator password. It is normal for these commands to produce no output.
Note on macOS versions The commands to flush the DNS cache have varied between macOS releases. The commands above cover the majority of recent versions (Catalina, Big Sur, Monterey, Ventura...). If you are running a much older release, consult Apple support before executing version-specific commands.
Linux (common examples)
The method depends on the active DNS caching service (systemd-resolved, nscd, dnsmasq, unbound, etc.). Examples:
- systemd-resolved (modern Ubuntu):
If resolvectl is not available:sudo resolvectl flush-cachessudo systemd-resolve --flush-caches - nscd:
sudo systemctl restart nscd # ou sudo service nscd restart - dnsmasq:
sudo systemctl restart dnsmasq # ou sudo service dnsmasq restart - unbound:
sudo systemctl restart unbound
If your distribution does not run a local caching daemon, there is nothing to flush on the workstation — name resolution will depend solely on the resolvers configured in /etc/resolv.conf.
Test name resolution (check that the new IP is visible)
- Query a public resolver to compare responses:
Replace 1.1.1.1 with 8.8.8.8 to query a different resolver.nslookup exemple.com 1.1.1.1 # ou (si dig installé) dig @1.1.1.1 exemple.com +short - If at least one public resolver returns the expected IP, the update is effective; other intermediate resolvers may still return the old response until the TTL expires.
- Tip for quick tests without editing the hosts file:
This command forces curl to connect to the IP 203.0.113.10 for the host exemple.com (useful for verifying the site before propagation). Warning: with HTTPS, you may encounter a certificate warning if the server’s certificate does not include the forced IP.curl -I --resolve exemple.com:443:203.0.113.10 https://exemple.com/
Still reaching the old server after a DNS change?
- Check the hosts file (takes precedence over DNS resolution):
- Windows:
C:\Windows\System32\drivers\etc\hosts(open in Notepad as administrator). - macOS / Linux:
/etc/hosts(edit withsudosudo and an editor like nano).
If a line maps your domain to an old IP, remove it, save the file and flush the local cache again.
- Windows:
- Clear/close the browser cache or open a private browsing window (browsers sometimes keep DNS resolutions in memory).
- Restart the router/modem (some hardware keeps an internal DNS cache).
- Query multiple resolvers to compare responses:
If one returns the new IP and the other does not, the discrepancy is due to an intermediate cache (a resolver) waiting for the TTL to expire.nslookup exemple.com 1.1.1.1 nslookup exemple.com 8.8.8.8 - Check the TTL of the DNS record and wait: propagation can take up to the TTL duration (sometimes 24–48 hours depending on the case). For a planned cutover, reduce the TTL 24–48 hours before the change.
- If the zone is managed via cPanel, open the Zone Editor and verify that the A/CNAME records are correct — modify them if necessary (see below).
- Temporary solution to access the new server immediately:
- Locally modify the hosts file to point the domain to the new IP (warning: remember to undo the change after testing).
- Or use
curl --resolveas shown above to test without modifying the hosts file.
Do not distribute hosts changes across multiple machines without a centralized procedure — this complicates the migration.
cPanel illustrations (if you manage the zone from cPanel)
If your zone is managed via cPanel, open the Zone Editor from the dashboard to verify or correct the A/CNAME records:
Best practices and limitations
- Flushing the local cache does not affect the caches of intermediate resolvers (ISPs, public DNS) that respect the TTL.
- For a migration: reduce the TTL 24–48 hours before the cutover, make the change, verify propagation, then raise the TTL again once stable.
- Do not leave temporary entries in the hosts file after testing; they can prevent correct access for visitors.
- With HTTPS, forcing a local IP can trigger a certificate warning (certificate name ≠ domain). Use this method only for testing.
Quick command summary
- Windows:
ipconfig /flushdns(see alsoipconfig /displaydnsandnetsh winsock reset). - macOS (recent versions):
sudo killall -HUP mDNSResponder sudo killall mDNSResponderHelper sudo dscacheutil -flushcache - Ubuntu / systemd-resolved:
sudo resolvectl flush-caches(orsudo systemd-resolve --flush-cachesdepending on the version). - nscd:
sudo systemctl restart nscdorsudo service nscd restart.sudo systemctl restart dnsmasqdnsmasq: - Test the resolution:
nslookup exemple.com 1.1.1.1ordig @1.1.1.1 exemple.com +short.
Troubleshooting: what to provide to support
If, after these checks, the site still returns the old IP from multiple public resolvers, open a ticket indicating:
- The domain name and the expected IP.
- The date/time of the DNS change.
- The outputs of the commands executed (e.g. the output of
dig @1.1.1.1 exemple.com +shortornslookup exemple.com 1.1.1.1). - The TTL observed for the modified record.
This article is written for non‑technical users. If you would like us to perform the check for you, include the domain name and the expected IP in your ticket.
Reference documentation
- How to Clear Your DNS Cache — cPanel Documentation
Documentation consulted on 16 October 2026. Tools may vary depending on your hosting.