Connecting a remote server to Compass?

Hello. Since I’m very new to this topic of working with MongoDB on a remote Virtual Private Server, things are a bit more complicated than that on my side.

My Node.JS app and MongoDB Community Edition are both on a remote Ubuntu server.
I remember when working with MongoDB on my local Windows 10 machine, I had to activate it with mongod , first. Only then I could enter the Mongo shell in another PowerShell instance with mongo .

A. What if my website’s end users want to add or remove data to and from my in-server database? Will the server keep mongod command active even if I don’t do that? Is such thing even necessary in this scenario?

This article says I have to use the IP address of my remote server hosting MongoDB when trying to connect to it (from for example a Win10 machine) when using Compass:

I’ve changed the bind_ip to 0.0.0.0 in /etc/mongodb.conf

B. Is this URI string correct for connecting Compass to the remote server db:

mongodb://<IP address of ubuntu server>:27017/?tls=true

I used this URI string in my app when using the MongoDB cluster:
mongodb+srv://<username>:<password>@<some address>.mongodb.net/?retryWrites=true&w=majority

C. Where is the username and password when MongoDB is installed on a remote server? Do I have to create them in Mongo shell on the remote server? If yes, then how?

D. Does creating a user on in-server database change the URI string for Compass? Does it have something to do with Authentication Method section in Compass?

E. In absence of such user, can Compass access the in-server db directly?

I know that’s a lot. I appreciate your help.

Hi :wave: @mj69,

Welcome to the MongoDB Community forums :sparkles:

If you start MongoDB as a service on Ubuntu, it will be running in the background and your web server will have access to the database until you shut it down manually - Reference

If you are open to using a managed service, I recommend that you consider using MongoDB Atlas before deploying a database manually, as an improperly configured database may pose security risks.

You need to configure security and access control - Please refer to the MongoDB Security Checklist. You should enable authentication, configure a Role-Based Access Control, and configure network encryption with TLS.

This depends on whether you wish to use Compass as a different user. In some cases, you might not want to run Compass as a super user on a regular basis. For this purpose, it would be necessary to create a user with limited permissions and use that user as part of the Compass connection string.

MongoDB Compass can connect to local or remote deployments.

To gain a deeper understanding of MongoDB, I would recommend you take these courses from MongoDB University.

I hope it helps!

Thanks,
Kushagra

2 Likes

Thank You. How can I connect to MongoDB Community Edition installed on my server without SSH, remotely?

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