Skip to content

Instantly share code, notes, and snippets.

@stokito
Last active October 26, 2023 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/8a24a0597e13478a3acf4d4d3171523f to your computer and use it in GitHub Desktop.
Save stokito/8a24a0597e13478a3acf4d4d3171523f to your computer and use it in GitHub Desktop.
Fix problem: Ubuntu can't open any website

My laptop batery discharged while I slept and look like my file system was broken. Or maybe I run an update and forgot. Anyway, after reboot I still had a problem: no any website was opening with some weird error that DNS can't be resolved.

And yes, the ping doesn't worked for any domain. Dig was failed too. It turned out that systemd-resolvd DNS daemon didn't started. I checked logs with

journalctl -u systemd-resolved

In logs I found that the resolved fails with an error "cannot allocate memory".and after that the servive crashed.

/etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf which is is absen because it's created in runtime by the systemd-resolved. So I manually created the file in order to temporary fix the DNS:

echo "nameserver 1.1.1.1" > /run/systemd/resolve/resolv.conf

After that DNS started working and at least from Chrome I was able to open Google. The apt install worked too because internally it uses plain HTTP.

But the curl was still failed to get any HTTPS website: "curl: (35) insufficient randomness" I also remmember some errors like "PRNG is not seeded" or somehting like that.

So I executed the curl with strace and checked which file does it opens:

strace curl https://ubuntu.com

Among them I found /usr/lib/ssl/openssl.cnf which is a symlink to /etc/ssl/openssl.cnf . So I decided to just backup it and remove for now:

sudo mv /etc/ssl/openssl.cnf /etc/ssl/openssl.cnf.bak

That helped and the curl and anything else now works perfectly with the TLS. It loook like the file was broken but I can't tell exactly because ther is no any visual problems. Anyway this helped, hope the memo will help you to figure out your problem

UPD the file is installed by openssl package. I reinstalled it and the file was recreated and the problem ocurred again. The bakup file has no difference with the version from a package. After upgrade to Ubuntu 23.10 the problem disapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment