changing domain name for Mongodb primary
To add replica set members with hostname, pass the host name when initializing the replica set.

rs.initiate(
    {
        _id: "config",
        version: 1,
        members: [
        {_id: 0, host: "vagrant-ubuntu-trusty-64:27022"}
        ]
    }
)



  _id --> is your replica set name


Or if you want to edit the existing configuration follow the below steps

var conf = rs.conf()

conf.members[0].host="vagrant-ubuntu-trusty-64:27022"

rs.reconfig(conf)



  If you have more than one member in your replica set, all members
  should refer a hostname. Which means all members should be localhost or all members should be hostnames