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

后端 未结 6 508
失恋的感觉
失恋的感觉 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: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.

提交回复
热议问题