I start my mongoDB. it’s running ,but i can’t connect to it
Here’s the error description in mongod.log:
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on /tmp/mongodb-27017.sock: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on 127.0.0.1:27017: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on /tmp/mongodb-27017.sock: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on 127.0.0.1:27017: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on /tmp/mongodb-27017.sock: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on 127.0.0.1:27017: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on /tmp/mongodb-27017.sock: Bad file descriptor
2023-09-04T17:05:35.643+0800 I NETWORK [listener] Error accepting new connection on 127.0.0.1:27017: Bad file descriptor
I searched and didn’t seem to be able to find a solution, I’ve tried to delete the file “/tmp/mongodb-27017.sock” and change it’s permission to “mongod:mongod”, and it didn’t work.
I’ve also tried repairing, and it didn’t work
Could you share the MongoDB version you are using, the OS, and whether you have deployed it on a VM or Docker?
Can you check if the /tmp directory has write permissions for the mongod user/group. Run ls -ld /tmp to verify. If not, run sudo chmod 777 /tmp to allow write access.
Also check for any other processes that may be blocking port 27017 or have the socket file open.
In case the above steps don’t resolve the issue, try reinstalling MongoDB freshly which will overwrite the socket file, and restart everything cleanly.
It seems you are using the outdated version of the MongoDB server. We recommend updating your MongoDB version to the latest release. MongoDB 4.0 is no longer supported, and upgrading to a newer version can provide improved stability, bug fixes, and additional features. You can refer to the EOL Support Policies for more information on MongoDB versions and their support status.