WSL icon indicating copy to clipboard operation
WSL copied to clipboard

DNS resolution broken in WSL after timezone change: "Clock change detected. Flushing caches" loop

Open mihalt opened this issue 1 month ago • 5 comments

Windows Version

10.0.19045.6456

WSL Version

2.6.1.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

6.6.87.2-1

Distro Version

Ubuntu 22.04.5 LTS

Other Software

Docker version 28.5.2, build ecc6942

Repro Steps

  1. Change timezone in WSL (e.g., via Ansible or manually).
  2. Restart WSL.

Expected Behavior

  • Timezone changes should not break DNS resolution.
  • systemd-resolved should not flush caches aggressively due to minor time adjustments.
  • WSL should maintain network connectivity regardless of time sync issues.

Actual Behavior

  • DNS resolution fails permanently.
  • Network connectivity is lost (even ICMP).
  • Manual fixes (disabling systemd-timesyncd, restarting services) do not resolve the issue.

Diagnostic Logs

After changing the timezone in WSL (using Ansible task community.general.timezone) to match the host system, DNS resolution stopped working entirely. The timezone was already the same as on the host, but the change triggered a cascade of issues:

  1. systemd-resolved constantly flushes DNS cache Logs systemctl status systemd-resolved show repeated messages:
systemd-resolved[139]: Clock change detected. Flushing caches.

This prevents any DNS resolution, as the cache is cleared before queries can complete.

  1. systemd-timesyncd fails to sync time Logs systemctl status systemd-timesyncd show timeouts when trying to reach NTP servers:
systemd-timesyncd[146]: Timed out waiting for reply from 91.189.91.157:123 (ntp.ubuntu.com).

This creates a "chicken and egg" problem: DNS fails because time is unstable, and time sync fails because DNS is broken.

  1. No network connectivity. Even basic ping 1.1.1.1 fails with:
From 172.23.150.55 icmp_seq=1 Destination Host Unreachable

Attempt fixes (none worked):

sudo timedatectl set-ntp false
sudo systemctl stop systemd-timesyncd
sudo systemctl disable systemd-timesyncd
sudo systemctl restart systemd-resolved
sudo hwclock -s

Disabled WSL time sync as per Microsoft docs. Restarted WSL (wsl --shutdown).

Can be usefull my current status too:

$ timedatectl status
               Local time: Mon 2025-11-24 00:50:13 EET
           Universal time: Sun 2025-11-23 22:50:13 UTC
                 RTC time: Sun 2025-11-23 22:50:13
                Time zone: Europe/Warsaw (EET, +0200)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no

Docker containers located in this wsl works fine.

mihalt avatar Nov 23 '25 23:11 mihalt

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions in Collect WSL logs for networking issues

Once completed please upload the output files to this GitHub issue.

See Collect WSL logs (recommended method).

If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

github-actions[bot] avatar Nov 23 '25 23:11 github-actions[bot]

/emailed-logs

mihalt avatar Nov 23 '25 23:11 mihalt

Diagnostic information
Found '/emailed-logs', adding tag 'emailed-logs'

github-actions[bot] avatar Nov 23 '25 23:11 github-actions[bot]

sudo timedatectl set-timezone UTC

Done the job! 😅

mihalt avatar Nov 24 '25 07:11 mihalt

I've found that this problem didn't resolve the problem of dns flush (but dns worked):

systemd-resolved[125]: Clock change detected. Flushing caches.

Also, absolutely unexpectedly the problem has been restored today. I couldn't resolve any dns names inside wsl again. And the change from the previous message didn't help. Just the windows reboot helped.

I've also had in my /etc/wsl.conf file the string that I commented.

#[boot]
#systemd=true

I hope that it will resolve the problem. But I would need systemd inside my wsl, for another tasks. For example to connect via ssh as to a separate machine.

mihalt avatar Nov 25 '25 13:11 mihalt

One funny thing. Docker Desktop is turning on some time

$ timedatectl
               ...
          System clock synchronized: no
          NTP service: inactive
          RTC in local TZ: no
$ ping google.com
ping: google.com: Temporary failure in name resolution

After I turned off Docker Desktop:

$ timedatectl
                ...
          System clock synchronized: yes
          NTP service: inactive
          RTC in local TZ: no
$ ping google.com
PING google.com (142.251.98.113) 56(84) bytes of data.
64 bytes from nt-in-f113.1e100.net (142.251.98.113): icmp_seq=1 ttl=113 time=24.5 ms

I even didn't wsl --shutdown. It just worked on the same terminal.

So, looks like the problem is strongly connected with Docker Desktop.

mihalt avatar Dec 12 '25 09:12 mihalt

The complete deletion of Docker Desktop 4.54.0 resolved the problem of systemd-resolved[139]: Clock change detected. Flushing caches. comprehensively.

Installation of new Docker Desktop inherits the problem. I've checked on another devices with different configurations. With Docker Desktop 4.39.0 and inside /etc/wsl.conf:

[boot]
systemd=true 

is the same clock change problem immidiately after Docker Desktop starts and correctly work after the Docker Desktop quit.

If I do direct install inside WSL as in Ubuntu OS, then everything is fine.

I think, this topic can be helpfull to any of this guys too: https://github.com/microsoft/WSL/issues/11318 https://github.com/microsoft/WSL/issues/10006 https://github.com/microsoft/WSL/issues/11790

mihalt avatar Dec 12 '25 14:12 mihalt

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions in Collect WSL logs for networking issues

Once completed please upload the output files to this GitHub issue.

See Collect WSL logs (recommended method).

If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

github-actions[bot] avatar Dec 12 '25 14:12 github-actions[bot]

One more funny thing now, that with uninstalled Docker Desktop on Windows side and natively installed docker engine inside Ubuntu of wsl, I don't have any clock errors. I don't have any errors connected with timesyncd or resolved. Even Ubuntu journalctl is without errors. But looks like, that DNS switches on and switches off randomely after some time. Even with stopped windows firewal and docker engine in Ubuntu:

sudo systemctl stop docker
sudo systemctl stop docker.socket

mihalt avatar Dec 12 '25 15:12 mihalt