Solved Can't Start MongoDB40 "SocketException: Permission denied"

Hello. I've just setup a FreeBSD 12.1-RELEASE-p3 system, and installed mongodb40 via "pkg install mongodb40". If it's relevant, I've also made the path "/var/db/mongodb" a ZFS pool with a 4K record size. I've been unable to get mongod to run as the user "mongodb", checking the logs, I'm getting the error "SocketException: Permission denied", I don't get this error as root, but I don't want to run the db as root. I'm not very experienced with FreeBSD, but I haven't been able to find any sort of permission I should be giving the mongodb user. Here is where I've gotten stuck:

Code:
root@freebsd:/home/user # service mongod start
Starting mongod.
/usr/local/etc/rc.d/mongod: WARNING: failed to start mongod
root@freebsd:/home/user # tail /var/db/mongodb/mongod.log
2020-04-04T05:39:51.679-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1d-freebsd 10 Sep 2019
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] allocator: system
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] modules: none
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] build environment:
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] distarch: x86_64
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] target_arch: x86_64
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] options: { config: "/usr/local/etc/mongodb.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/db/mongodb/mongod.lock", timeZoneInfo: "/usr/share/zoneinfo" }, setPa
rameter: { disabledSecureAllocatorDomains: "*" }, storage: { dbPath: "/var/db/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/db/mongodb/mongod.log" } }
2020-04-04T05:39:51.680-0400 E STORAGE [initandlisten] Failed to set up listener: SocketException: Permission denied
2020-04-04T05:39:51.680-0400 I CONTROL [initandlisten] now exiting
2020-04-04T05:39:51.680-0400 I CONTROL  [initandlisten] shutting down with code:48

Thank you for your time :).
 
That could be a permission/ownership (user group) problem with /tmp. Adapt to your needs.

Thank you. For anyone in the future looking for a solution, I simply executed the following to alleviate the error:

Code:
chmod 777 /tmp

Though, this will allow any user full write access to /tmp, probably not a big deal, default permissions are 755 anyways. Something to keep in mind though.
 
Though, this will allow any user full write access to /tmp, probably not a big deal, default permissions are 755 anyways.
Default permissions on /tmp are actually 1777 (the same applies to /var/tmp), don't forget to set the sticky(7) bit!
 
Back
Top