I received this error in the terminal of my Kali Linux VM (VirtualBox). My VM did not connect to the internet. Even the ping command didn't work. The following steps fixed my issue.
Select the Kali VM in VirtualBox
Go to Settings > Network
Select NAT (Adapter 1)
Restarted the VM