Slow webpage responses / pings on NixOS

Hello, can someone help me debug slow webpages / pings on NixOS.

When I open webpages, it often takes ~20seconds until I get an output. Afterwards everything is pretty fast. I have also ran a speedtest which gave back normal results of 250/50.

This is what happens when I time a ping command:

[user@nixos:~]$ time ping speedtest.net
PING speedtest.net (151.101.194.219) 56(84) bytes of data.
64 bytes from 151.101.194.219: icmp_seq=1 ttl=59 time=12.4 ms
64 bytes from 151.101.194.219: icmp_seq=2 ttl=59 time=11.9 ms
^C
--- speedtest.net ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 5030ms
rtt min/avg/max/mdev = 11.869/12.125/12.382/0.256 ms

real    0m5,411s
user    0m0,003s
sys    0m0,001s

As you can see, it takes about 5 real time seconds until the first response happens. Can someone help me debug this further, I don’t know where to start. Thank you!

Info about my system:
NixOS 25.05 on stable channel using flakes

The ping itself looks okay. Maybe check your DNS settings. If the first DNS server in the list is not reachable then there is typically some delay.

This was indeed a DNS issue. I have previously tested DNS and encountered no issues.
I am using adguardhome and some of the queries got dropped due to a ratelimit in the config that is set to 20 by default.

Without the ratelimit, I don’t have this issue anymore. Seems like I just had luck when testing dns so the ratelimit wasn’t reached.