-mongodb version 4.0.4
-macOS Mojave
Problems
- Try to connect mongodb using the REMOTE_IP address on my mac machine, always encounter the error message as shown below.
server-0 | MongoError: failed to connect to server [REMOTE_IP:27017]
on first connect [MongoError: connect ECONNREFUSED REMOTE_IP:27017]
- Use the telnet client to connect the mongodb
telnet REMOTE_IP 27017
- Error message as shown below is displayed
Trying REMOTE_IP...
telnet: connect to address REMOTE_IP: Connection refused
telnet: Unable to connect to remote host
Solutions
- Open mongod.conf file that located at /usr/local/etc folder, add the REMOTE_IP into the file
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1,REMOTE_IP
- Restart mongodb using the command below, please include the path of mongod.conf in the command.
# mongod --config /usr/local/etc/mongod.conf
- Use the telnet client to connect the mongodb, it will work like a charm!
telnet REMOTE_IP 27017
Small quote: How people treat you is their karma, how you react is yours!
No comments:
Post a Comment