Unable to connect to mongodb Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112

后端 未结 17 920
不知归路
不知归路 2021-02-02 14:45

When ever I try to connect to mongo db I always get this error as below.

MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution f

相关标签:
17条回答
  • 2021-02-02 14:54

    Same error here, this worked for me:

    sudo mongod --repair
    

    followed by

    sudo mongod
    

    (forget about service and start)

    Then on a different tab/terminal:

    mongo
    
    0 讨论(0)
  • 2021-02-02 14:54

    If you create data\db folder, firstly you must delete this folder then execute:

    c:\mongodb\bin\mongo.exe 
    
    0 讨论(0)
  • 2021-02-02 14:54

    If you are on unix-like systems.

    Starting in MongoDB 4.4, a startup error is generated if the ulimit value for number of open files is under 64000. View the current val

    $ ulimit -n
    

    Change value

    $ ulimit -n <val>
    
    0 讨论(0)
  • 2021-02-02 14:57

    I had the same issue until i close teamviewer running on my pc. Then it worked fine!

    0 讨论(0)
  • 2021-02-02 14:58

    Quick Fix: I have the same problem to start the MongoDB and it was easily fixed by running the file mongod.exe (C:\Program Files\MongoDB\Server\3.2\bin) then run the file mongo.exe (C:\Program Files\MongoDB\Server\3.2\bin)..Problem fixed

    0 讨论(0)
  • 2021-02-02 14:59
    mongod --configsvr --smallfiles --nojournal --dbpath cfg/1 --port 26052 --fork --logpath cfg/3.log >/dev/null
    

    Create a single mongos server on the default port

    sleep 2000
    mongos --configdb ${HOSTNAME}:26050,${HOSTNAME}:26051,${HOSTNAME}:26052 --fork --logpath mongos.log >/dev/null
    

    Sleep for some time before starting the mongos you will not face the problem

    0 讨论(0)
提交回复
热议问题