how to setup mongodb replica on cloud server? I want to setup mongodb repicaset on my cloud server(AWS ec2) but I have only one IP address. 
Currently I have make /etc/hosts two entries 127.0.0.1 dbnode1 and xx.xx.xx.xx dbnode2 but when I try to reconfig rs config its give error.

Error:- Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: node1:27017; the following nodes did not respond affirmatively: node2:27019 failed with Error connecting to node2:27019 (127.0.0.2:27019) :: caused by :: Connection refused

Can anyone suggest how to I can setup replica or without setup replica how to use transaction query.
If you try to set up replica set of two (or more) nodes at one physical server... You must use IP-addresses and not host names. So 127.0.0.1:27017, 127.0.0.1:27019