Search code examples
mongodb

MongoDB Fails On Reboot - Socket Exception


I am having an error on boot. From what I've found, this error happens when trying to assign an IP that is not available on the local interface. I'm currently unable to post to mongodb community forum for some reason so I'm posting here, if this is the wrong place, feel free to inform me but I think it's acceptable as it's a software tool that's commonly used.

Device Information: Raspberry Pi 5 using Ubuntu Server 24.04 LTS

Specific Error:

{"t":{"$date":"2024-06-10T08:14:20.621-05:00"},"s":"E",  "c":"CONTROL",  "id":20568,   "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"setup bind :: caused by :: Cannot assign requested address"}}}

Log File - Unable to upload file so hastebin is being used

Config File

Mongod.service file

I've ran the command ifconfig -a | grep "inet" and the output is as follows:

inet 192.168.1.214  netmask 255.255.255.0  broadcast 192.168.1.255
inet6 fe80::2ecf:67ff:fe2e:a51e  prefixlen 64  scopeid 0x20<link>
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10<host>

I've removed the 192.168.1.214 portion of the bindIP, and it would start just fine after a reboot. I can manually start the service without issues with that IP (192.168.1.214, separated by the first IP with a comma) in the config file.

Edits

  1. I recently discovered that I'm unable to connect VIA Mongo shell or MongoDB Compass unless I am tunneling VIA SSH, which was not the case before sometime last week

Solution

  • Solution:

    As Wernfried Domscheit pointed out in this https://stackoverflow.com/a/74610881/3027266, I did bindIpAll: true, which fixed the issue on boot.

    In short, bindIp: localhost is used to allow connections from the machine only, and bindIpAll will allow remote connections.