This error took me an hour to solve

You need to make sure the hostname is on the first line and should match the hostname of the server. All the documentation I see mentions something like mail.domain.com. This leads to confusion because usually your server hostname is going to be something else.

This is what my host file looks like which let me proceed

Also, make sure you use the actual IP of your server and not the loop back IP address