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

前端 未结 27 2560
孤街浪徒
孤街浪徒 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:17

    There are changes in mongod.conf file in the latest MongoDB v 3.6.5 +

    Here is how I fixed this issue on mac os High Sierra v 10.12.3

    Note: I assume that you have installed/upgrade MongoDB using homebrew

    mongo --version

    MongoDB shell version v3.6.5 
    git version: a20ecd3e3a174162052ff99913bc2ca9a839d618 
    OpenSSL version: OpenSSL 1.0.2o  27 Mar 2018 
    allocator: system modules: none build environment:
    distarch: x86_64
    target_arch: x86_64
    
    1. find mongod.conf file

       sudo find / -name mongod.conf` 
      

      /usr/local/etc/mongod.conf > first result .

    2. open mongod.conf file

      sudo vi /usr/local/etc/mongod.conf
      
    3. edit in the file for remote access under net: section

       port: 27017  
       bindIpAll: true 
       #bindIp: 127.0.0.1 // comment this out
      
    4. restart mongodb

      if you have installed using brew than

      brew services stop mongodb
      
      brew services start mongodb
      

    otherwise, kill the process.

       sudo kill -9 
    

提交回复
热议问题