Unable to connect to mongodb Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112

后端 未结 17 922
不知归路
不知归路 2021-02-02 14:45

When ever I try to connect to mongo db I always get this error as below.

MongoDB shell version: 2.4.3 connecting to: test Fri Apr 26 14:31:46.941 JavaScript execution f

相关标签:
17条回答
  • 2021-02-02 15:05

    First start mongod service then mongo or mongos

    0 讨论(0)
  • 2021-02-02 15:05

    Mongo DB requires space to store it files. So you should create folder structure for Mongo DB before starting the Mongodb server/client.

    for e.g. MongoDb/Dbfiles where Mongo DB is installed.

    Then in cmd promt exe mongod.exe and mongo.exe for client and done.

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

    I am using version 4.0.6 ( the current release) on Linux Mint. You need to install Mongodb Compass(mongodb GUI) to interact with your databases. Here is the link: https://docs.mongodb.com/compass/master/install/

    I hope this solves your problem.

    0 讨论(0)
  • 2021-02-02 15:09

    Please Start the MongoDB server first and try to connect.

    Pre-requisite:

    Create space for storing DB and tables in any directory Example (windows): D:\mongodbdata\

    Steps:

    1. Start server

      mongod --port 5000 --dbpath D:\mongodbdata\ (please mention above created path)

    2. Connect mongodb server (Run in another terminal/console)

      mongo --port 5000

    0 讨论(0)
  • 2021-02-02 15:12

    Faced same issue, my understanding is(it could be wrong)
    1. Make sure mongodb is up and running
    2. For linux access as sudo and for windows if connecting localhost turning off firewall may help but its not necessary
    3. Just type mongo, it will try to connect to localhost by default. You need to specify IP if you are connecting to a remote server. By default test db will be used.

    0 讨论(0)
  • 2021-02-02 15:14

    Start mongod server first

    mongod
    

    Open another terminal window

    Start mongo shell

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