Search code examples
mongodbmongodb-queryspring-data-mongodbmongodb-.net-driver

Why MongoDB connection string starts with mongodb:\\


Why should I use the following syntax :

mongodb:\\localhost:27017 

The localhost part I got but, why it does not works when I skip the mongodb:\ prefix ?


Solution

  • Why MongoDB connection string starts with mongodb:\

    It doesn't, the slashes should be forward slashes:

    mongodb://localhost:27017 
    

    Why? This is the format of the URI as agreed upon by the people who designed it.