Mongodb with visual studio code? Mongodb should be connected to database error

How can I get MongoDB to work locally, is it any different than glitch? I have been using visual studio code and heroku thus far but can’t get mongo to connect.

There’s a few terms being thrown around here I want to clarify

  • MongoDb - mongodb is a database and the name of the company that created it and also potentially refers to mongodb-atlas which is a service by the company to provide the database as a service to end users.

    • I assume you have a mongodb instance installed locally on your machine and “can’t connect to it”.
    • Otherwise maybe your actually using an atlas instance and can’t connect to that
  • VSCode - an IDE/text-editor application that can be used to write your code, and with the power of plugins do other stuff.

  • heroku - a cloud service provider where you can host applications you write.

  • glitch - an online IDE + service provider where you can write and run applications you write.


So Mongodb+VSCode isn’t exactly a combination as a text-editor/IDE doesn’t have anything directly to do with your database. You could use VSCode to write an application that connects to your database though.

A local mongodb-instance is its own application, that if you got running acts like any other instance, in that you connect to it via a string with some security parameters (name and password to the instance).

Finally Heroku can host that application you wrote, and can connect to mongodb but can’t connect to your local machine instance. You probably will need to use something like mongodb-atlas which can run your database instance and allow heroku to connect to it then.

note there are some potential “gaps” not mentioned, like you could be using a plugin in VSCode to connect to mongodb and it isn’t working, but as that isn’t mentioned I didn’t look int it.

1 Like

Okay thank you I just had not put my database name and it was defaulting to test.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.