How to fix Linux Could not resolve hostname problem
If you have hostname in your /etc/hosts file but you still get "Could not resolve hostname" issue, check /etc/nsswitch.conf
The order of name resolution is actually defined in /etc/nsswitch.conf, which usually has this entry:
hosts: files dns
which means "try files (/etc/hosts); and if it fails, try DNS."