Couldn't connect to server 127.0.0.1:27017 connection attempt failed MongoDB

前端 未结 8 1282
灰色年华
灰色年华 2021-02-04 17:05

I am working on Ubuntu OS 16.04. I am starting mongodb using commands:: sudo service mongod start and then mongo

It generated this error for m

相关标签:
8条回答
  • 2021-02-04 17:23

    mongod --repair worked for me ,

    sudo mongod --repair
    sudo mongod
    

    Then open a different tab/terminal:

    mongo
    

    After this your local setup will work properly

    0 讨论(0)
  • 2021-02-04 17:23

    This error occurs when your mongodb server is not running on 27017 port. Try the below command to start the mongodb server.

    sudo systemctl start mongod
    

    And after running this command run the mongo command.

    0 讨论(0)
  • 2021-02-04 17:24

    On MacOS , I executed the 4th step of this https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x-tarball/

    tutorial with sudo

    sudo mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log --fork

    and It worked!

    0 讨论(0)
  • 2021-02-04 17:27

    MAC: For my case I forgot to turn on mongo server locally, so I fixed the issue by firstly open a new tab on terminal then turn on mongodb server like so: -

    mongod 
    

    After that just try to open mongo shell again like so: -

    mongo 
    

    Finally it worked!

    0 讨论(0)
  • 2021-02-04 17:31

    Windows

    • Open task manager.
    • click on the services tab.
    • Search for MongoDB service.
    • After selecting click on the 'view services' tab.
    • Search for MongoDB server.
    • After Selecting click on the Run button on the top left side menu.

    And you are good to go.

    0 讨论(0)
  • 2021-02-04 17:31

    i too got the same problem.here is the way how i resoleved.go to taskmanager.select>services and find mongodbserver in the list make sure the mongodb is running by selecting it.

    image source

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