Failed to establish a new connection: [Errno -3] Name resolution temporarily failed')':
This is the one.
If you leave the Raspberry Pi unattended, this will happen frequently and you will forget how to deal with it.
sudo dhclient wlan0
This command seems to set the IP address borrowed from the DHCP (Dynamic Host Configuration Protocol) server. The DHCP server is the one that assigns the IP to the device connected to wifi.
The first time I encountered it, apt-get failed. It seems that it was an error that I could not connect to the Internet because the IP was not assigned to Raspberry Pi.
Because I was able to ssh PC → wifi → Raspberry Pi This route was being followed Also, even if I hit the internal IP with ping, there was no problem, so I thought that I was able to connect to the Internet.
I was a little troubled because there seems to be a mysterious thing that even if the internal IPs are connected to each other, it is not possible to connect to the Internet via wifi.