mongo - couldn't connect to server 127.0.0.1:27017

后端 未结 30 2233
故里飘歌
故里飘歌 2020-11-27 09:43

I am coming from riak and redis where I never had an issue with this services starting, or to interact.

This is a pervasive problem with mongo and am rather clueless

相关标签:
30条回答
  • 2020-11-27 10:28

    This was happening with me today and I resolved it in following way.

    Machine: I'm using Windows 10 machine and downloaded the latest MongoDB - Community edition.

    So, the problem was, I did not have C:\data\db created.

    Without creating C:\data\db, I opened CMD terminal and started the database using mongod command at terminal

    C:\YourInstallationPath\bin>mongod

    And when I fired mongo command then I was getting the problem.

    Twist, I created the necessary folders but still was getting the problem. And this is because mongo server was already running. To fix it, I fired up mongod command again, and it automatically referenced to C:\data\db.

    Other users have suggested to add C:\data\db but did not talk about executing mongod again, which exactly solved my problem.

    0 讨论(0)
  • 2020-11-27 10:28

    First, go to c:\mongodb\bin> to turn on mongoDB, if you see in console that mongo is listening in port 27017, it is OK If not, close console and create folder c:\data\db and start mongod again

    0 讨论(0)
  • 2020-11-27 10:29

    I had the same error when connecting to Mongo on AWS EC2 . This is what solved it https://serverfault.com/a/347159/62381 Remove the bind_ip from the config file

    0 讨论(0)
  • 2020-11-27 10:29

    Finally I got this is in a simple way..

    open terminal and go to the mongodb location. In my case it is

    e:\mongodb\bin> 
    

    and type the following command and press enter..

    mongod --config e:\mongodb\mongo.config
    

    Open another terminal and start the mongodb using

    mongo.exe
    

    Thats it.. you can use mongo

    0 讨论(0)
  • 2020-11-27 10:30

    Make sure that your mongo is running. I fixed this problem by trying to repair the mongodb, there I found that the directory required for the db to run was not created. It shows this error

    Type: mongod, it will show the error

    exception in initAndListen: 29 Data directory /data/db not found., terminating

    Error happen because dbpath /data/db/ (default config) does not exist. You need to create data folder and set permission for it.

    Then I create a folder on my system by the command

    sudo mkdir -p /data/db/ and sudo chown id -u /data/db

    then I run the mongo again and it worked.

    0 讨论(0)
  • 2020-11-27 10:32

    MAC OS

    Check status

    brew services list
    

    Something like:

    Name    Status  User Plist
    mongodb stopped  
    

    start it

    brew services start mongodb
    

    Try it again

    mongo or mongo --port 27017

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