Found the solution from stackexchange. It seems like a DNS server problem. Did the below and it started working.
Add the below line in /etc/nsswitch.conf:
hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4
I also had to change the name servers:
Change /etc/resolv.conf so it points to the google nameservers.
# RED 2013-03-31
nameserver 8.8.8.8
nameserver 8.8.4.4