Trouble launching mongoDB on a Rasberry Pi with systemd

I am having a problem with starting mongoDB on a Rasberry Pi with systemd, using Raspberry Pi OS 64 bits.

This is my environment:

root@raspberrypi:~ # uname -a
Linux raspberrypi 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux
root@raspberrypi:~ # 
root@raspberrypi:~ # mongo --version
MongoDB shell version v4.4.4
Build Info: {
    "version": "4.4.4",
    "gitVersion": "8db30a63db1a9d84bdcad0c83369623f708e0397",
    "openSSLVersion": "OpenSSL 1.1.1d  10 Sep 2019",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "ubuntu1804",
        "distarch": "aarch64",
        "target_arch": "aarch64"
root@raspberrypi:~ # 

And this is the configuration file for the mongod server:

root@raspberrypi:~# cat /home/mongodb/mongo-One.cfg
  dbPath: /mnt/mongoDB-One/DB_Data
    enabled: true
  port: 22330
  destination: file
  path: /mnt/mongoDB-One/DB_Data/mongod.log
  logAppend: true
  replSetName: mngoRepSet

This is the systemd service file:

root@raspberrypi:~# cat /lib/systemd/system/mongod-One.service
Description=MongoDB Database Server

ExecStart=/usr/bin/mongod --config /home/mongodb/mongo-One.cfg
# file size
# cpu time
# virtual memory size
# open files
# processes/threads
# locked memory
# total threads (user+kernel)

# Recommended limits for mongod as specified in


In this configuration the server starts as expected (note that the bindIp line in the server configuration is commented out). But troubles come when I remove the comment on the bindIp line.

I then get this error in the logs:

{"t":{"$date":"2021-03-20T12:51:15.862+09:00"},"s":"E", "c":"STORAGE", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Cannot assign requested address"}}}

It seems to show a network issue, but I have done everything I can think of in the systemd service file to make sure the network would be ready when starting the service. Can someone see something I am missing?

I can also confirm that after failing at boot time, the service can be manually started using:

root@raspberrypi:~ # systemctl start mongod-One

The IP isn’t there yet to bind to.

A systemd/init issue. There seems to be quite a few hits on google regarding this, so there is bound to be one that solves this.

Are you addressing more than 1 ip/interface on this host? If not I would just bind_ip_all.

No I am not addressing more than one ip/interface on this host.

I used bind_ip_all as you suggest and it works.

Since I don’t know yet what it implies to use this instead of what I was doing before, I cannot tell if this is a good solution on the long term. But at least on the short term, it solves my problem. The server starts at boot time and then I can initiate a replica set and use mongoDB normally.

The thing to be aware of is that any interface added to the system, or any ip added to an existing interface, will be listening on the mongod port too.

If adequate system and/or database protections are in place this really isn’t an issue.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.