Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

前端 未结 27 2522
孤街浪徒
孤街浪徒 2020-12-12 15:06

while trying this mongo command in ubuntu I am getting this error.

    ritzysystem@ritzysystem-Satellite-L55-A:~$ mongo
    MongoDB shell version: 2.6.1
             


        
相关标签:
27条回答
  • 2020-12-12 15:10

    I just removed mongo following the instructions here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ And then I installed again following the instructions in the given link. Everything worked smoothly!

    0 讨论(0)
  • 2020-12-12 15:11

    I had the same problem on my Mac, and I installed mongodb via homebrew. I solve this problem by the homebrew services command.

    First start mongodb service:

    $ brew services start mongodb

    Start mongodb terminal

    $ mongo

    Stop mongodb service:

    $ brew services stop mongodb

    0 讨论(0)
  • 2020-12-12 15:11

    I faced the same problem, so please check is there mongodb folder, firstly try to remove that folder

    rm -rf /var/lib/mongodb/*
    

    Now try to start mongo and if same problem then its mongodb lock file which prevent to start mongo, so please delete the mongo lock file

    rm /var/lib/mongodb/mongod.lock
    

    For forcefully rm -rf /var/lib/mongodb/mongod.lock

    service mongodb restart if already in sudo mode otherwise you need to use like sudo service mongod start

    or you can start the server using fork method

    mongod --fork --config /etc/mongod.conf
    

    and for watching the same is it forked please check using the below command

    ps aux | grep mongo
    
    0 讨论(0)
  • 2020-12-12 15:15

    Mongo 3.*.* - OSX - 2017

    From README

    RUNNING
    

    Change directory to mongodb-osx-x86_64-3.*.*/bin

    To run a single server database:

    $ mkdir /data/db
    $ ./mongod
    

    Go to new Terminal

    $ # The mongo javascript shell connects to localhost and test database 
    $ # by default -Run the following command in new terminal
    $ ./mongo 
    > help
    
    0 讨论(0)
  • 2020-12-12 15:16

    Run the following command :

    sudo rm /var/lib/mongodb/mongod.lock
    sudo service mongod restart
    

    Connection refused to MongoDB errno 111

    MacOS:

    rm /usr/local/var/mongodb/mongod.lock  
    sudo service mongod restart
    
    0 讨论(0)
  • 2020-12-12 15:16

    Make sure you have run the MongoDB's Service before you want to connect the console.

    run and start the server:

    $ sudo mongod
    

    then:

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