My current MongoDB configuration,
options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.0.204", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid", timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
Here's the issue I am having,
2018-02-02T19:16:32.017+0800 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2018-02-02T19:16:32.017+0800 I CONTROL [initandlisten] now exiting
2018-02-02T19:16:32.017+0800 I CONTROL [initandlisten] shutting down with code:48
First solution on *nix: You could bind_ip = 0.0.0.0 and use a firewall to block all incoming connections to port 27017, unless coming from local ip adress. Second solution
Restart mongo:
> service mongod restart
Go to to /var/logs/mongodb and give the information from logs.
Let try to test mongo, is it running localy with default options?
> service mongod status
That tells you the status of mongo. If it disactive, go to logs, in my case it /var/logs/mongodb get info from log.
Then, lets try to start mongo without remote IP option. goto /etc/mongod.conf and set up option only on local ip, bindIp 127.0.0.1 then
service mongod restart
and
service mongod status
Is it running? If everything is fine, You need determine what your's local lan ip addres.
in my case it was command, other commands link
LANG=c ifconfig | grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'
After that add it ip addres to mongo conf with comma separated option. like: bindIp 127.0.0.1, 192.168.1.66
than save config and simply restart mongo
service mongod restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With