mongo - couldn't connect to server 127.0.0.1:27017

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

    OK, this may be strange. My error happened because my log grew exponentially and clogged up server space hence mongo didn't get enough space to store anything.

    so I cleared the log

    > /var/log/mongod.log
    
    0 讨论(0)
  • 2020-11-27 10:44

    try this one:

    get into the bin folder on terminal, then write:

    sudo ./mongod --dbpath <write_here_the_path_to_your_database>, click enter. (always do same thing).

    then sudo ./mongo

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

    Remove mongod.lock file. And run "mongod -repair". uninstall/reinstall mongod service fixed that problem for me.

    Thanks.

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

    Another solution that resolved this same error for me, though this one might only be if you are accessing mongo (locally) via a SSH connection via a virtual machine (at least that's my setup), and may be a linux specific environment variable issue:

    export LC_ALL=C
    

    Also, I have had more success running mongo as a daemon service then with sudo service start, my understanding is this uses command line arguments rather then the config file so it likely is an issue with my config file:

    mongod --fork --logpath /var/log/mongodb.log --auth --port 27017 --dbpath /var/lib/mongodb/admin
    
    0 讨论(0)
  • 2020-11-27 10:46

    if all the solution above doesn't work out perhaps then this might be one to help. Somewhere down the line you may have made connection to your local mongodb database via vagrant boxes.

    1. vagrant up and then ssh into your vagrant machine in which you've made connection with mongodb (vagrant ssh vagrant_box_name)
    2. comment out the bind_ip line from /etc/mongod.conf using # (sudo nano /etc/mongod.conf )
    3. restart your mongodb daemon service (sudo service mongod restart) voila...
    0 讨论(0)
  • 2020-11-27 10:49

    in my case in windows and ubuntu, i needed to create /data/db folder in root. In ubuntu, i needed one additional option; to give permissions for directory.

    windows

    mkdir c:/data/db
    

    ubuntu:

    sudo mkdir -p /data/db
    sudo chmod 700 /data/db
    

    then run

    sudo service mongod start
    

    check

    sudo service mongod status
    

    and then run

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