MongoDB couldn’t initiate : can’t find self in the replset config

Error: When use coomand rs.initiate()

{ “errmsg” : “couldn’t initiate : can’t find self in the replset config”, “ok” : 0 }

Cause: a hostname(s) of a replica set member(s) cannot be resolved

Solution: Add hostname(s) in /etc/hosts