By default, MongoDB doesn’t allow remote connections. to enable the remote access bind the ip address of the machine in mongod.conf.
in linux /etc/mongod.conf
# network interfaces net: port: 27017 bindIp: ip-address of the machine // by default it will be 127.0.0.1