Cannot Start mongodb-community

Hello,

I tried every solution here but I still get the same error when I try to start mongodb-community edition through brew services start mongodb-community
or
brew services restart mongodb-community
or
brew services start mongodb-community@6.0

I deleted the 27017.sock file and tried these things again. At some point I always get the same error when I
brew services list

Name Status User File
mongodb-community error 3584 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

And this error while trying to restart.
Error: Failure while executing; /bin/launchctl bootstrap gui/501 /Users/macbook/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist exited with 5.

When I tried to start it “sudo”, I get the error below;
Error: Failure while executing; /bin/launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.mongodb-community.plist exited with 37.

Can anyone help me on this? This really got my days and I’m frustrated.

Have you looked at the MongoDB log file to see what’s being written to it? That should have the error that’s happening. If you can post the log showing the most recent attempt to start the process we can use that to help you out.

Also note that you shouldn’t ever run the MongoDB process as the root user (running with sudo) as this sets permission on files/directories that cause issues when you try to run as your normal user. Running as root can also lead to escalation of privileges and allow for bad things to happen.

{"t":{"$date":"2022-10-04T18:29:00.238+03:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/Users/macbook/Desktop/mongodatabasepathtest","storageEngine":"wiredTiger"}}
{"t":{"$date":"2022-10-04T18:29:00.238+03:00"},"s":"W",  "c":"STORAGE",  "id":22302,   "ctx":"initandlisten","msg":"Recovering data from the last clean checkpoint."}
{"t":{"$date":"2022-10-04T18:29:00.238+03:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=3584M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,remove=true,path=journal,compressor=snappy),builtin_extension_config=(zstd=(compression_level=6)),file_manager=(close_idle_time=600,close_scan_interval=10,close_handle_minimum=2000),statistics_log=(wait=0),json_output=(error,message),verbose=[recovery_progress:1,checkpoint_progress:1,compact_progress:1,backup:0,checkpoint:0,compact:0,evict:0,history_store:0,recovery:0,rts:0,salvage:0,tiered:0,timestamp:0,transaction:0,verify:0,log:0],"}}
{"t":{"$date":"2022-10-04T18:29:00.948+03:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":1,"message":"[1664897340:946133][2690:0x11404f600], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: int __posix_open_file(WT_FILE_SYSTEM *, WT_SESSION *, const char *, WT_FS_OPEN_FILE_TYPE, uint32_t, WT_FILE_HANDLE **), 805: /Users/macbook/Desktop/mongodatabasepathtest/WiredTiger.turtle: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2022-10-04T18:29:00.951+03:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":1,"message":"[1664897340:951390][2690:0x11404f600], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: int __posix_open_file(WT_FILE_SYSTEM *, WT_SESSION *, const char *, WT_FS_OPEN_FILE_TYPE, uint32_t, WT_FILE_HANDLE **), 805: /Users/macbook/Desktop/mongodatabasepathtest/WiredTiger.turtle: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2022-10-04T18:29:00.952+03:00"},"s":"E",  "c":"WT",       "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error message","attr":{"error":1,"message":"[1664897340:952344][2690:0x11404f600], wiredtiger_open: [WT_VERB_DEFAULT][ERROR]: int __posix_open_file(WT_FILE_SYSTEM *, WT_SESSION *, const char *, WT_FS_OPEN_FILE_TYPE, uint32_t, WT_FILE_HANDLE **), 805: /Users/macbook/Desktop/mongodatabasepathtest/WiredTiger.turtle: handle-open: open: Operation not permitted"}}
{"t":{"$date":"2022-10-04T18:29:00.952+03:00"},"s":"W",  "c":"STORAGE",  "id":22347,   "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}
{"t":{"$date":"2022-10-04T18:29:00.952+03:00"},"s":"F",  "c":"STORAGE",  "id":28595,   "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"1: Operation not permitted"}}
{"t":{"$date":"2022-10-04T18:29:00.952+03:00"},"s":"F",  "c":"ASSERT",   "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":702}}
{"t":{"$date":"2022-10-04T18:29:00.952+03:00"},"s":"F",  "c":"ASSERT",   "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

Is it something like this? I used
tail $(brew --prefix)/var/log/mongodb/mongo.log

to get this.

The following sticks out:

It seems like there are data files in the dbPath that are not compatible with the version of MongoDB that you are running. You can either delete all the files in this path if the data is not needed. If you need/want to keep this data, then you can move them off in a new location and then try to figure out what version of MongoDB those files were created with and start that version of the mongod process at a later time. Once you have a clean dbPath directory, try running your brew services restart ... command again and see if you can get the process started.

1 Like

Hello,

I have changed my config file. And the dbPath part is empty now. This is how my config file looks right now.

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath:
net:
  bindIp: 127.0.0.1, ::1
  ipv6: true

However, this time I get another error when I try to restart my mongo community. This is the error right now.

Name              Status       User File
mongodb-community error  25600 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

After this error I checked this link

And I changed dbPath line to:

dbPath: /usr/local/var/mongodb

However, I get another error which has the sam error number like the first one (3584), like the one below:

Name              Status      User File
mongodb-community error  3584 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

When I try to open the file in the error, I get an error like this.

The file /Users/macbook/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist does not exist.

Because I have deleted that file formerly.

This is the latest log.

macbook@SamsMacbook ~ % tail $(brew --prefix)/var/log/mongodb/mongo.log            
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"CONTROL",  "id":5945603, "ctx":"main","msg":"Multi threading initialized"}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"CONTROL",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":31154,"port":27017,"dbPath":"","architecture":"64-bit","host":"SamsMacbook.local"}}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.1","gitVersion":"32f0f9c88dc44a2c8073a5bd47cf779d4bfdee6b","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"21.3.0"}}}
{"t":{"$date":"2022-10-07T19:11:33.261+03:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/usr/local/etc/mongod.conf","net":{"bindIp":"127.0.0.1, ::1","ipv6":true},"storage":{"dbPath":true},"systemLog":{"destination":"file","logAppend":true,"path":"/usr/local/var/log/mongodb/mongo.log"}}}}
{"t":{"$date":"2022-10-07T19:11:33.262+03:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Permission denied"}}
{"t":{"$date":"2022-10-07T19:11:33.262+03:00"},"s":"F",  "c":"ASSERT",   "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":1120}}
{"t":{"$date":"2022-10-07T19:11:33.262+03:00"},"s":"F",  "c":"ASSERT",   "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

Can you guys help me please? I’ve been struggling for days. Thank you.

It says failed to unlink tmp .socket file.Check permissions/ownership of this file
Most likely owned by root from your previous run
You have to remove this file and start service again
Also make sure your dbpath directory is empty and has appropriate permissions on it for mongod to write onto it

What file should I remove? How can I change the root? How do I change the permissions mongod to write?

Check
ls -lrt /tmp/mongod-27017.sock
ls -lrt /usr/…/…/mongodb

As Ramacchandra states, the socket file is most likely owned by the root user and can safely be removed by running sudo rm /tmp/mongod-27017.sock.

One thing I notice is that in your brew services lists output it shows the user of mongodb-community as root. You should be installing and running MongoDB as your regular user. The MongoDB process should never be run as the root user unless you are directed to by MongoDB support team for troubleshooting, and even then only if you understand the implications of what happens when you run the service as the root user. This could lead to privilege escalation which could then lead to bad things happening.

macbook@SamsMacbook ~ % sudo rm /tmp/mongod-27017.sock.
Password:
rm: /tmp/mongod-27017.sock.: No such file or directory

I get this when I write something like @Ramachandra_Tummala said.

macbook@SamsMacbook ~ % ls -lrt  /usr/local/var/mongodb    
total 0

I don’t know what installing as a regular user means. I deleted the mongo and reinstalled it many times. Nothing works.

macbook@SamsMacbook Library % ls -l /tmp/mongodb-27017.sock
srwx------  1 root  wheel  0  7 Eki 18:44 /tmp/mongodb-27017.sock

This is the situation right now. I thought I have removed the file but whenever I write this command, the result show up.

macbook@SamsMacbook ~ % ls -l /tmp/mongodb-27017.sock
srwx------  1 root  wheel  0  7 Oct 18:44 /tmp/mongodb-27017.sock

UPDATE

I found the .sock file and deleted it with sudo rm

However this time I get the error below;

macbook@SamsMacbook ~ % brew services list
Name              Status       User File
mongodb-community error  25600 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

And now this is the log;

macbook@SamsMacbook /tmp % brew services list                     
Name              Status       User File
mongodb-community error  25600 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
macbook@SamsMacbook /tmp %  tail $(brew --prefix)/var/log/mongodb/mongo.log
{"t":{"$date":"2022-10-08T16:45:24.399+03:00"},"s":"I",  "c":"ASIO",     "id":22582,   "ctx":"MigrationUtil-TaskExecutor","msg":"Killing all outstanding egress activity."}
{"t":{"$date":"2022-10-08T16:45:24.399+03:00"},"s":"I",  "c":"COMMAND",  "id":4784923, "ctx":"initandlisten","msg":"Shutting down the ServiceEntryPoint"}
{"t":{"$date":"2022-10-08T16:45:24.399+03:00"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-10-08T16:45:24.399+03:00"},"s":"I",  "c":"CONTROL",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-10-08T16:45:24.399+03:00"},"s":"I",  "c":"CONTROL",  "id":4784928, "ctx":"initandlisten","msg":"Shutting down the TTL monitor"}
{"t":{"$date":"2022-10-08T16:45:24.400+03:00"},"s":"I",  "c":"CONTROL",  "id":6278511, "ctx":"initandlisten","msg":"Shutting down the Change Stream Expired Pre-images Remover"}
{"t":{"$date":"2022-10-08T16:45:24.400+03:00"},"s":"I",  "c":"CONTROL",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-10-08T16:45:24.400+03:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-10-08T16:45:24.400+03:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2022-10-08T16:45:24.400+03:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}

I just dont even know what is going on at this point. All I ever wanted to do is setting up an environment an start my backend tutorial. I dont know if this is normal or not but I’m not sure if I ever use Mongo again.

Do you guys know why doesn’t anything work? Or any suggestion?

Hello guys,

I have solved the problem.

When the error was error 3584, what I did was to delete the 27017.sock file as you have said before.
I did this using these commands one by one; (I’m sure there are easier ways but I wanted to see everything clearly.)

macbook@SamsMacbook ~ % cd /tmp
macbook@SamsMacbook /tmp % ls -a
macbook@SamsMacbook /tmp % sudo rm mongodb-27017.sock

And then restarted the mongo.

macbook@SamsMacbook ~ % brew services restart mongodb-community

I saw this error when I check if it is working properly or not.

macbook@SamsMacbook ~ % brew services list
Name              Status       User File
mongodb-community error  25600 root ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

I have learned that this is caused because of the .conf file details. How to reach it? Easy.

macbook@SamsMacbook ~ % open /usr/local/etc/mongod.conf

The file includes some code like this;

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, ::1
  ipv6: true

See if there is different than the one I shared above. My dbPath was empty. I changed it to the default value I found in the internet.

dbPath: /usr/local/var/mongodb

And then, we command

brew services restart mongodb-community

That’s all folks! These are the solutions for error 3584 and error 25600 in Mongo.

Thanks @Doug_Duncan and @Ramachandra_Tummala

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