Singam
Singam

Reputation: 503

MongoDB is not working on Mac High Sierra

I am trying to run MongoDB(4.4.16) on Mac High Sierra(10.13.6). When I run the server with command ./mongod from the bin folder of the installation, I see the following log:

{"t":{"$date":"2022-09-06T10:16:16.208+01:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-09-06T10:16:16.227+01:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2022-09-06T10:16:16.232+01:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":529,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"Users-iMac.local"}}
{"t":{"$date":"2022-09-06T10:16:16.232+01:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.16","gitVersion":"a7bceadbac919a2c035f2874c61d138fd75d6a6f","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-09-06T10:16:16.233+01:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"17.7.0"}}}
{"t":{"$date":"2022-09-06T10:16:16.233+01:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2022-09-06T10:16:16.241+01:00"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db"}}
{"t":{"$date":"2022-09-06T10:16:16.243+01:00"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2022-09-06T10:16:16.247+01:00"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"STORAGE",  "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-09-06T10:16:16.248+01:00"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-09-06T10:16:16.249+01:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-09-06T10:16:16.249+01:00"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}

First, surprisingly there is no message of the like that MongoDb started successfully.

Second, when from another tab of the terminal window, I attempt to access the database, I get a connection refusal:

MongoDB shell version v4.4.16
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

How can I fix this issue?

Many Thanks

Upvotes: -1

Views: 223

Answers (1)

James Risner
James Risner

Reputation: 6074

Credit to @deceze, the root cause is a read-only filesystem.

I'll address several of the reasons a filesystem can be read-only in macOS High Sierra and future versions.

NTFS filesystem format is a read-only format for macOS.

Most common with external hard drives, especially new ones that come pre-formatted.

You can confirm the directory (in your case /data/db) is NTFS by opening Disk Utility. You should see NTFS or Windows NT Filesystem as shown here: NTFS

You may resolve this by reformating the external hard drive.

The disk or directory with read-only disk permissions.

Find and right-click on the icon of your disk or directory then choose "Get Info". If you see only read with no write permission, then click on the lock to enter your password and unlock the tool. Next click on the "Read only" right of your name and select "Read & Write" instead.

permissions

Corrupt disks are also often mounted read only.

A corrupt disk is protected from being mounted read/write to avoid damaging the data or a kernel panic on corrupt disk info. To resolve this you open Disk Utility and select the disk. Right click and choose "Run First Aid". Once it completes it should say "operation successful" with a green check mark. successful

Upvotes: 0

Related Questions