connect ECONNREFUSED 127.0.0.1:27017'

前端 未结 8 1081
南旧
南旧 2021-01-13 19:36

I have that code:

var express = require(\'express\'),
    stylus = require(\'stylus\'),
    logger = require(\'morgan\'),
    bodyParser = require(\'body-par         


        
相关标签:
8条回答
  • 2021-01-13 19:59

    run services.msc and activate the Mongodb service.

    Now Mongodb will connect

    the status of the Mongodb indicated as Running

    0 讨论(0)
  • 2021-01-13 20:00

    try this:

    mongod.exe --dbpath c:\data\db

    c:\data\db is the place where you put your db.

    and when you see something like this :

    2016-08-18T10:22:31.020+0800 I CONTROL  [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
    2016-08-18T10:22:31.022+0800 I CONTROL  [initandlisten] MongoDB starting : pid=4356 port=27017 dbpath=c:\data\db 64-bit host=sevencai-PC0
    2016-08-18T10:22:31.022+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
    2016-08-18T10:22:31.023+0800 I CONTROL  [initandlisten] db version v3.2.8
    2016-08-18T10:22:31.023+0800 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
    

    ......

    and then node yourserver.js

    maybe everything will be fine!

    0 讨论(0)
  • Follow as below:

    => run services.msc and start mondodb server

    and save the file in node project, you can see the server connected!!

    0 讨论(0)
  • 2021-01-13 20:07

    Your mongodb service is probably down. Run sudo service mongod start to start the daemon process

    0 讨论(0)
  • 2021-01-13 20:09

    If you're in windows and you had this issue, just go the installer exe app for the mongodb and click "Repair" this works for me

    0 讨论(0)
  • 2021-01-13 20:12

    I was having the same problem, and found that it was a mongod issue.(I am running Ubuntu 16.04). Looking through the errors there was a directory missing. After adding the directory, I needed to change permissions, and finally, set the mongod service to start at boot.

    $ sudo mkdir -p /data/db
    $ sudo chown -R $USER /data/db
    $ sudo systemctl enable mongod.service
    
    0 讨论(0)
提交回复
热议问题