Mongodb://username:password@{ip_address}:27017 | '{ip_address}' what does it mean hear?

i’m new to Mongodb & & studying mongodb native driver for nodejs. when i look into a project which’ ve got a mongoURL connection string as follow: mongodb://username:password@{ip_address}:27017
Could somebody explain to me what does the {ip_address} really mean here?
as what i’ ve read in the Mongo Docs( that the mongoURL connection string should look kind of like as below:
what is the difference here? please
Thanks in advance!

1 Like

@aphong Hi,

Not an expert but I’ll give you some pointers:

  • mongodb+srv://

    :mag: mongodb+srv: indicates the following string is a srv string (the program will return a list of servers from that seed). This is used for replica sets (a set of computers running instances of mongod and working together). For standalone (single computer) you omit the srv i.e (mongodb://etc).
    :mag: username:password, no need for clarifications, but when using the CLI you can omit username and password off the string and pass it as arguments --username <username> and also --password <password>
    :mag: this is a standard url like you paste in the browser, all urls more or less are names to a server/computer. This will be translated to an IP address. If you know the IP address, you can just replace it therein. You could literally paste that into a browser (not much will happen though). For example:
    Where the IP can be either public or private. In this case is private and it is pointing to my own PC in the LAN. Find your IP using (ipconfig or ifconfig).
    :mag: name: it is the name of the db you authenticate against if authSource option is absent. In any case though, is the database you currently log in into.
    :mag: a=b, c=d are just key value pairs used to pass information in the url. Most search engines use the same pattern, example hello - Google Search.

You can use all that to analyze this connection string:


And checkout the docs for connection string if you like knowing more.


Great! really appreciated @Santiago, your infor is much easier for me to understand ;), I’m bad at English so I haven’t got the whole idea of Mongo Docs until you shed some light.
But my question still remains unanswered.
=> Why do they have to put the ‘ip_address’ in curely brackets like this ‘{ip_address}’? please
=> What is it good for ?

1 Like

@aphong no, that’s a way to say “what is inside must be replaced by an IP”. For example: {name} would mean, replace {name} by your name.

It seems a silly question but it is important and also it is not agreed upon many languages how to describe values supposed to be replaced.

To finish up the answer {ip_address} would end up being or any IP.

You will also see sometimes <ip_address> which has exactly the same meaning and would be replaced by or any IP.


Nice! you just open my eyes @Santi Thanks for your kind & support : )
From what I see, they must replace this {ip_address} with their own IP address when deploying this project which has the above mongodb connection string inside of a .env file
recently I teach myself programming from zero. So lots of interesting things but for sure it’s not easy to understand all stuff at once.

1 Like

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