MongoError: connect ECONNREFUSED 127.0.0.1:27017

后端 未结 21 1289
我在风中等你
我在风中等你 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 08:42

    For Ubuntu users run sudo systemctl restart mongod

    0 讨论(0)
  • 2020-12-14 08:43

    Try to start mongoDB server by giving the --dbpath with mongod.

    sudo mongod --dbpath /var/lib/mongo/data/db &
    

    '&' in the last will start the mongodb server as service on your server.

    Hope it Works.

    0 讨论(0)
  • 2020-12-14 08:43

    In my particular instance, I was connected to a VPN and that was blocking the localhost connection to MongoDB somehow. It worked when I disconnected my VPN. It's a special case, but good to know nonetheless. So anything impeding your network connectivity, Get that fixed.

    0 讨论(0)
  • 2020-12-14 08:44

    I had the same error because i had not installed mongoDB. Make sure that you have mongodb installed and if not, you can download it from here https://www.mongodb.com/download-center/community

    0 讨论(0)
  • 2020-12-14 08:44

    For Windows users.

    This happens because the MondgDB server is stopped. to fix this you can,

    1. 1 search for Services ,for that search using the left bottom corner search option.

      2 then there is a gear icon named with 'Services'.

      3 after clicking that you will get a window with lot of services

      4 scroll down and you will find 'MongoDB server (MongoDB)'.

      5 so you will see that there is an option to start the service.

      6 start it.

    2. 1 then open your command prompt.

      2 type mongod

    now you can connect to your server.

    this steps also working fine if your sql server service down. (find sql server services)

    0 讨论(0)
  • 2020-12-14 08:45

    This happened probably because the MongoDB service isn't started. Follow the below steps to start it:

    1. Go to Control Panel and click on Administrative Tools.
    2. Double click on Services. A new window opens up.
    3. Search MongoDB.exe. Right click on it and select Start.

    The server will start. Now execute npm start again and the code might work this time.

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