MongoError: connect ECONNREFUSED 127.0.0.1:27017

后端 未结 21 1290
我在风中等你
我在风中等你 2020-12-14 08:40

I\'m using NodeJS wih MongoDB using mongodb package. When I run mongod command it works fine and gives "waiting for connection on port 27017". So, mongod seems to

相关标签:
21条回答
  • 2020-12-14 09:05

    I've forgot to start MongoDB at all. Go to separate tab in terminal and type:

    sudo service mongod start
    
    0 讨论(0)
  • 2020-12-14 09:06

    Please ensure that your mongo DB is set Automatic and running at Control Panel/Administrative Tools/Services like below. That way you wont have to start mongod.exe manually each time.

    0 讨论(0)
  • 2020-12-14 09:06

    I was having the same problem today.. and has been searching for answers.. I am on Ubuntu... however, I could not find the correct one that works on this thread.. after much research the following worked for me finally!! :)

    First, after running

    mongod dbpath
    

    if appeared that mongodb was looking for the data/db directory.. which was missing in my installed mongodb app.. so I ran the following commands:

    $ sudo mkdir -p /data/db
    

    then run,

    $ sudo chown -R $USER /data/db
    

    chown - changes ownership of files/dirs. Ie. owner of the file/dir changes to the specified one, but it doesn't modify permissions. As detailed here: https://unix.stackexchange.com/questions/402062/how-are-chown-and-chmod-command-different-in-the-given-operation

    Finally, run

    `$ sudo systemctl enable mongod.service
    

    It will give a message: Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service and started the service.

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