mongo - couldn't connect to server 127.0.0.1:27017

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

    I was getting this error on ubuntu but you can try with the following command:

    sudo service mongod start
    
    0 讨论(0)
  • 2020-11-27 10:24

    Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it.

    This error caused because Mongo Server been closed

    Simple Follow these steps

    1. Open Task Manager
    2. Go to >Services
    3. Find MongoDB
    4. Right click and select Start
    0 讨论(0)
  • 2020-11-27 10:27

    The cause by me was the space - run this in the console:

    df -h
    

    or more specifically:

    du -hs /var/lib/mongodb/ 
    

    to check he disk usage. If it's ~ 99% - just clean up some space and try again!

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

    I am a windows user and I installed MongoDB in November 2018 and I didn't wanted to setup data/db directories. But after few days, when I open, got an error message:

    MongoDB shell version v4.0.4
    connecting to: mongodb://127.0.0.1:27017
    2018-12-05T20:42:40.108+0530 E QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. :
    connect@src/mongo/shell/mongo.js:257:13
    @(connect):1:6
    exception: connect failed
    

    Then I tried to fix using all of above answers and didn't worked. When I tried to run mongod it said

    MongoDB starting : pid=12220 port=27017 dbpath=C:\data\db\ 64-bit host=bla
    

    I tried to change the db path(to program files) through file system and also using cmd but those didnot worked.

    Solution that worked for me is:

    Opened the Task Manager (ctrl + shift + esc) -> Services tab and there was a MongoDB row with the status stopped. Then I right clicked and clicked start and everything working perfectly :).

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

    If all the above solution does not work: go to service (start>search>services) and start mongodb service. Then, in a cmd prompt, after going to bin, type :/>mongo

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

    Start monogdb service using

    sudo service mongod start 
    

    then from the new window or terminal start mongo client using

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