mongoDB error: Error: failed to connect to [localhost:27017]

后端 未结 6 510
失恋的感觉
失恋的感觉 2021-02-06 12:45

I\'m trying to install habitrpg locally but I keep getting a mongoDB error after typing node src/seed.js:

Error: failed to connect to [localhost:270         


        
相关标签:
6条回答
  • 2021-02-06 12:53

    I think that you don't have an environmental variable declared. Assuming that your MongoDB installation is C:\ProgramFiles\MongoDB\Server\YOUR_VERSION_NUMBER\, you should just add the bin folder path of that version of MongoDB to your PATH system environment variable.

    Here's a link where you can find the way to do that without complications : http://www.computerhope.com/issues/ch000549.htm

    0 讨论(0)
  • 2021-02-06 12:55

    After installing MongoDb you have to add the directory "data\db" under the C:\ directory, then you should start the mongod.exe

    0 讨论(0)
  • 2021-02-06 12:58
    1. Open CMD (In Windows) or terminal (In Ubuntu).

    2. type command >cd PATH_FOR_MONGODB_BIN_FOLDER

      cd C:\Program Files\MongoDB\Server\3.2\bin

      for ubuntu command will be same :

      cd /home/MongoDB/Server/3.2/bin

    3. then type command >mongod --dbpath PATH_FOR_DATA_FOLDER

      mongod --dbpath C:\data\db

      For ubuntu command will be :

      ./mongod --dbpath /home/data/db

      you can specify any folder as data folder.

    4. Wait till CMD or Terminal shows "waiting for connections"

      2016-09-01T21:38:33.170+0530 I NETWORK [initandlisten] waiting for connections on port 27017

    5. Then open new CMD or terminal window.

    6. type command >cd PATH_FOR_MONGODB_BIN_FOLDER ( same as step 3 )

      cd C:\Program Files\MongoDB\Server\3.2\bin

      Don't close previous window of cmd or teminal.

    7. then run mongodb by typing "mongo" in windows or "./mongo" in ubuntu

      mongo

      For ubuntu

      ./mongo

    8. After mongodb run successfully you can close previous CMD window.

    0 讨论(0)
  • 2021-02-06 12:58

    I got this issue because I didn't have MongoDB. SO Installed MongoDB and tried to run node application and it worked.

    If you don't have MongoDB then follow below steps to install and enjoy

    Commands :

    $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
    
    $ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
    
    $ sudo apt-get update
    
    $ sudo apt-get install -y mongodb-org
    

    then type mongo in terminal and if you will get console for mongo then its done.

    0 讨论(0)
  • 2021-02-06 13:10

    You don't have MongoDB installed. Follow the directions for your system to install it: http://docs.mongodb.org/manual/installation/

    From the habitRPG docs:

    Before starting make sure to have MongoDB, NodeJS and npm and Git installed and set up.

    0 讨论(0)
  • 2021-02-06 13:15

    on windows open task manager || Ctrl + shift + ESC > select service tab > search for mongo db > right click > start service

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