Failed to unlink socket file [MongoDB]
Asked Answered
S

2

11

I am new to MongoDB & I am trying to install [email protected] to use mongo on Mac, I proceeded to all these steps by steps :

sudo brew install mongodb

mkdir -p /data/db

sudo chown -R -un' /data/db

mongo or mongod

until i got this on terminal :

{"t":{"$date":"2022-03-08T20:19:25.376+01:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2022-03-08T20:19:25.377+01: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-03-08T20:19:25.377+01:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":989}}
{"t":{"$date":"2022-03-08T20:19:25.377+01:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
mac@macs-MacBook-Pro ~ % mongod --dbpath ~/data/db
{"t":{"$date":"2022-03-08T20:21:23.974+01:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"thread1","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-03-08T20:21:23.974+01:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"thread1","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":13},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":13},"outgoing":{"minWireVersion":0,"maxWireVersion":13},"isInternalClient":true}}}
{"t":{"$date":"2022-03-08T20:21:23.974+01:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-03-08T20:21:23.974+01:00"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"thread1","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"thread1","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","ns":"config.tenantMigrationDonors"}}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"REPL",     "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","ns":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"CONTROL",  "id":5945603, "ctx":"thread1","msg":"Multi threading initialized"}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"CONTROL",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":69610,"port":27017,"dbPath":"/Users/mac/data/db","architecture":"64-bit","host":"macs-MacBook-Pro.local"}}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"5.0.6","gitVersion":"212a8dbb47f07427dae194a9c75baec1d81d9259","modules":[],"allocator":"system","environment":{"distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Mac OS X","version":"20.1.0"}}}
{"t":{"$date":"2022-03-08T20:21:23.976+01:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"storage":{"dbPath":"/Users/mac/data/db"}}}}
{"t":{"$date":"2022-03-08T20:21:23.977+01: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-03-08T20:21:23.977+01:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":989}}
{"t":{"$date":"2022-03-08T20:21:23.977+01:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}```
Skeptic answered 8/3, 2022 at 20:0 Comment(0)
E
15

Most probably you missed to shutdown properly your mongod previous time so there is socket file left in the tmp folder that you need to remove manually before you try to start the mongod process again:

    rm /tmp/mongodb-27017.sock
Ellersick answered 8/3, 2022 at 21:1 Comment(6)
i got this now : MongoDB shell version v5.0.6 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:372:17 @(connect):2:6 exception: connect failed exiting with code 1Skeptic
Is the mongod running ? Are you attempting to connect from same machine?Ellersick
what do you say about "same machine" ??Skeptic
any messages in the mongod logs , is it running?Ellersick
I just kill all terminal running and open new one to type mongo, it just that i made itSkeptic
when i type mongod i receive this again : 091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":989}} {"t":{"$date":"2022-03-08T23:45:29.171+01:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}Skeptic
P
0

this works for me if as Ubuntu User.

     rm -f /tmp/mongodb-27017.sock 
Perjury answered 7/9, 2023 at 2:25 Comment(1)
to identify the problem , rum this command in the terminal : ` sudo cat/var/log/mongodb/mongod.log. i got this message : { "msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}. Then I removed the filePerjury

© 2022 - 2024 — McMap. All rights reserved.