So I figured out my problem finally through browser developer tools after weeks of scratching my head why sometimes some page loads are super slow.
I saw that DNS lookup is sometimes really slow (2-3 seconds).
What can I do to fix it? Thank you.
I had issues with systemd-resolved
before. You can do the following:
Try disabling and stopping the systemd-resolved
service:
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
In the [main]
section of your /etc/NetworkManager/NetworkManager.conf
:
dns=default
Delete the symlink /etc/resolv.conf
:
rm /etc/resolv.conf
Restart NetworkManager
:
sudo systemctl restart NetworkManager
Then you can create /etc/resolv.conf
with your preferred DNS server specified in there.
Finally, test and check if you are getting a better performance out if it.
I had similar problems in the past, with slow or even failing DNS lookups.
It turned out to be DNS problems most probably related to the "ADSL modem"-ISP combination, as some (but not all) DNS lookups were timing out.
So, the problems were not related to my Ubuntu OS (either 18.04 or 20.04); the remedy was to simply reboot my ADSL modem.
/etc/hosts
file, be sure to have each domain/subdomain on its own line, even if you have multiple addresses going to the same IP. If your network has IPv6 support enabled, remember to include both the IPv4 and IPv6 addresses. This has bitten me in the past when local development page loads were slow but the open Internet was fast.