mongo - couldn't connect to server 127.0.0.1:27017

后端 未结 30 2230
故里飘歌
故里飘歌 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:33

    In my case:

    First I open config file

    sudo vi /etc/mongodb.conf
    

    Comment IP and Port like this

    #bind_ip = 127.0.0.1
    #port = 27017
    

    Then restart mongodb

    sudo service mongodb restart
    sudo service mongod restart
    

    Finally, it's work :D

    finn@Finn ~ $ mongo
    MongoDB shell version: 2.4.9
    connecting to: test
    > exit
    
    0 讨论(0)
  • 2020-11-27 10:34

    This error is what you would see if the mongo shell was not able to talk to the mongod server.

    This could be because the address was wrong (host or IP) or that it was not running. One thing to note is the log trace provided does not cover the "Fri Nov 9 16:44:06" of your mongo timestamp.

    Can you:

    1. Provide the command line arguments (if any) used to start your mongod process
    2. Provide the log file activity from the mongod startup as well as logs during the mongo shell startup attempt?
    3. Confirm that your mongod process is being started on the same machine as the mongo shell?
    0 讨论(0)
  • 2020-11-27 10:35

    I also have the same problem then I got fixed by these two lines of code. Hope, it helps

    systemctl start mongod
    systemctl enable mongod
    
    0 讨论(0)
  • 2020-11-27 10:36

    I face same issue after searching a lot I solve this by following :

    sudo service mongodb stop 
    
    sudo rm /var/lib/mongodb/mongod.lock 
    
    sudo mongod --repair --dbpath /var/lib/mongodb 
    
    sudo mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb 
    
    sudo service mongodb start
    
    0 讨论(0)
  • 2020-11-27 10:36

    Create the folder C:data/db if it doesn't already exist on your computer. Turns out MongoDB requires the existence of this folder structure 'data/db' to run. I hope this helps someone.

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

    A little to late with the answer but I've encountered the same issue

    Following are the steps which helped me.

    1. Go to C:\
    2. Create "data" folder
    3. In "data" create "db" folder
    4. open terminal (CMD) -> go to EX:"c:\MongoDB\Server\3.4\bin"
    5. type in mongod => this will start mongo server (leave it opened)

    Run using a GUI, EX "robomongo"

    Or

    open new terminal (CMD) -> go to EX:"c:\MongoDB\Server\3.4\bin" type in "mongo" command

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