Unable to set up mongod.config file on Windows

4,640 views
Skip to first unread message

Inner

unread,
Feb 7, 2016, 7:17:34 PM2/7/16
to mongodb-user
I have read the documentation on the configuration files, but it is not clear as to how I should create this file. I am unable to find the /etc directory, and am stuck since I need to change some of the configs in order to be able to remotely connect to my database from another computer. I have read

https://groups.google.com/forum/#!searchin/mongodb-user/config/mongodb-user/nEE638lCwqw/9BNOqSQ2iAsJ

but i do not see how I can create the config file from those commands. All help is appreciated, thank you.

Stephen Steneker

unread,
Feb 7, 2016, 7:25:45 PM2/7/16
to mongodb-user

On Monday, 8 February 2016 11:17:34 UTC+11, Inner wrote:

I have read the documentation on the configuration files, but it is not clear as to how I should create this file. I am unable to find the /etc directory, and am stuck since I need to change some of the configs in order to be able to remotely connect to my database from another computer.

Hi,

As at MongoDB 3.2, the Windows installer does not have a default location for a config file;  you have to provide the path to a config file when starting mongod.exe. The /etc directory sounds like a reference to a location for a Linux package install.

Typically you will want to Configure a Windows Service for MongoDB rather than running mongod.exe from the command line. The tutorial for configuring a Windows service also includes an example of creating a configuration file.

Regards,
Stephen

Inner

unread,
Feb 7, 2016, 8:51:46 PM2/7/16
to mongodb-user
I followed the instructions but when I called mongod --config
"C:\mongodb\mongod.cfg" --install, it said there is no such file or directory.
Is there a special way to create the .cfg file? Right now it is just a text file with the .cfg extension.

Stephen Steneker

unread,
Feb 7, 2016, 9:42:06 PM2/7/16
to mongodb-user

On Monday, 8 February 2016 12:51:46 UTC+11, Inner wrote:

I followed the instructions but when I called mongod —config
“C:\mongodb\mongod.cfg” —install, it said there is no such file or directory.

Is there a special way to create the .cfg file? Right now it is just a text file with the .cfg extension.

Hi,

There is no special way to create the config file .. it is indeed just a text file and the name/extension can be any valid filename.

Can you post the output of dir C:\mongodb\mongod.cfg and type C:\mongodb\mongod.cfg if the file exists?

Also, what are your versions of MongoDB and Windows O/S?

Thanks,
Stephen

Inner

unread,
Feb 7, 2016, 10:06:03 PM2/7/16
to mongodb-user
Thanks for the reply. I made the command "dir C:\mongodb\mongod.cfg.txt" and it worked when I called the --config command. However I still do not understand how I can add additional IP addresses to the bind_ip field, as it is not specified within my cfg file. Also, I noticed that it is not actually a .cfg file, but simply a .txt file named "config.cfg" which seems strange to me.

Stephen Steneker

unread,
Feb 7, 2016, 11:18:51 PM2/7/16
to mongodb-user

On Monday, 8 February 2016 14:06:03 UTC+11, Inner wrote:

Thanks for the reply. I made the command “dir C:\mongodb\mongod.cfg.txt” and it worked when I called the —config command.

Hi,

It sounds like your text editor may have automatically added a .txt extension when you saved the file as mongod.cfg.

As I mentioned, the config file can be any valid filename … mongod.cfg, mongod.cfg.txt, or mongod.txt would all work. There is no specific file type or extension required, but you may find it convenient to choose an extension that can be associated with your favourite text editor (eg. .txt).

However I still do not understand how I can add additional IP addresses to the bind_ip field, as it is not specified within my cfg file.

By default MongoDB listens to all local network interfaces. You can use the bindIp config option to specify a comma-separated list of IP addresses which are more restrictive than the default setting.

Note that the bind IP restriction only limits the network interfaces that the MongoDB server listens for connections on, and is not a substitute for configuring a firewall or role-based access control.

What are you trying to achieve with multiple bind IP addresses? Are you having issues connecting to your MongoDB server, or trying to restrict remote connections?

If you are trying to configure additional security for your MongoDB deployment please review the MongoDB Security Checklist.

Also, if you have any further questions on configuration please include the specific version of MongoDB server you are using. Relevant configuration options may vary depending on your version of MongoDB.

Regards,
Stephen

Inner

unread,
Feb 7, 2016, 11:41:57 PM2/7/16
to mongodb-user
Hi,

I was trying to remotely access my mongod instance from another computer. Thankfully, I have successfully made that happen. I am doing this since I want to host the database on a different machine than my application. I am using the intellij IDEA shell to connect remotely, which specifies an optional field for authentication. I am assuming this is the role-based access control you were referring to?

mayank bajpai

unread,
Jan 28, 2019, 4:08:25 PM1/28/19
to mongodb-user
Hi,

I am also trying to do the same but I am not able to succeed. Can you tell me how to do it?

Thanks,
Mayank
Reply all
Reply to author
Forward
0 new messages