Mongodb can't connect to localhost but can connect to localhost's IP address

后端 未结 5 2028
旧时难觅i
旧时难觅i 2020-12-06 16:45

If I try to run mongodb shell with the mongo command alone, I get:

Error: couldn\'t connect to server 127.0.0.1 shell/mongo.js:84
5条回答
  •  一整个雨季
    2020-12-06 17:33

    Just follow all these steps to solve this problem

    Step 1: Remove lock file.
    sudo rm /var/lib/mongodb/mongod.lock
    
    Step 2: Repair mongodb.
    mongod --repair 
    
    Step 3: start mongodb.
    sudo start mongodb 
    or
    sudo service mongodb start
    
    Step 4: Check status of mongodb.
    sudo status mongodb 
    or   
    sudo service mongodb status
    
    Step 5: Start mongo console.
    mongo
    

提交回复
热议问题