Cannot connect to mongodb errno:61 Connection refused

前端 未结 13 1263
心在旅途
心在旅途 2020-12-04 05:38

I recently installed mongodb-2.6.0 with Homebrew. After successfully installed, I tried to connect using the mongo command. I am receiving the following errors

13条回答
  •  执笔经年
    2020-12-04 06:14

    I had the same error but a different root cause. Thought I'd post the solution here in case anyone else runs into the problem. I got this error after my Mac improperly shut down while I was running mongorestore -d foo dump/foo/.

    tl;dr: I fixed the problem by removing the damaged foo.ns file along with foo.0, foo.1,... from my data folder /usr/local/var/mongodb/. Then I restarted the mongo server with brew services restart mongodb and I was back to normal.

    Details: I kept getting the error even after trying to start or restart the mongodb service via brew or launchctl. Eventually I ran mongod --dbpath /usr/local/var/mongodb and saw that the service was not actually starting, and the start sequence included the following error: [initandlisten] bad .ns file: /usr/local/var/mongodb/foo.ns [initandlisten] User Assertion: 10079:bad .ns file length, cannot open database I got rid of the bad .ns file and the rest of the data files, and the next time I started the service I was good to go.

提交回复
热议问题