Unable to create replica set for MongoDB in Linux
Your hostname must be an alias for 127.0.0.1 in your /etc/hosts file to make it work.

aldwin@myhostname~$ cat /etc/hostname 
myhostname
aldwin@myhostname:~$ hostname
myhostname
aldwin@myhostname:~$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   myhostname