This happens when you messes up with your hosts and hostname.
No worries I myself had this problem and solved it.
Just follow the steps below.
First check your hosts.
For doing so key the following in your terminal:
" cat /etc/hosts " - You should get the following.
""Forget the IPv6 parts and just focus on first 2 lines""
They should look the way I have shown:
If not you have to edit it and for doing so follow the steps given1 below:
Type : sudo gedit /etc/hostname /etc/hosts (in the terminal)
A test editor would open use it to open hosts tab and under remember to edit
127.0.0.1 localhost.localdomain localhost
and second one
127.0.1.1 -to your pc name(Whichever you have kept) .
edit the file under the hosts tab and save it.
You are then good to go.
No need to touch IPv6 settngs.
Please ! Check the link below more explanation about editing /etc/hosts:
http://ubuntuhandbook.org/index.php/2014/04/change-hostname-ubuntu1404/IMAGE OF How your hosts file should look
Hope this helps.
I searched this over Internet when I myself stumbled over THIS!!!
Now it's solved.