Retaining MongoDB remote connection during Nodemon local app restarts - mongodb

I am currently developing an application that uses a remote MongoDB database. Is there a way to retain the existing connection to the remote database when Nodemon restarts the app locally?

Related

Connect to a remote database running in a Docker container from another container running on different machine

I am facing the following situation:
I have a docker container (db) running a PostgreSQL database on my machine.
Furthermore, currently I have another container (server), which can successfully connect to that database from the same machine.
However, what I want is to connect to the db database from the server container, even if it is running on different machine. How could I do that?
I found this: https://www.codegrepper.com/code-examples/whatever/how+to+connect+to+remote+postgres+database+from+command+line
and this: https://www.a2hosting.com/kb/developer-corner/postgresql/remote-postgresql-connections#Method-2.3A-Set-up-a-direct-connection.
Both solutions make connection to the machine running the db container through ssh. However, I can whitelist only some valid users to be able to ssh to the machine running the db container, but not the user (which is the root) of the server container.
I hope my question is clear!
Thanks for any help!
p.s.: both containers are defined in a docker-compose file.

Problem to connect mongo DB replica set from linux, single instance run ok. Using .net core mongo driver

I am trying to connect an application in .net core from a linux machine to a mongo replicaset. But I am getting a timeout error.
Unhandled exception. System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector
The replica ips are accessible from this machine, a response is obtained by pinging.
If in linux the connection to mongo is to a single instance of the replica, it works correctly.
This same code in windows connects without problem.
If you are certain IP connectivity works, most likely you have the hostnames wrong. The hostnames used in RS config must work from each client.
See https://github.com/p-mongo/mongodb-faq.

Thousands of mongo connections on EC2

My server is running on AWS EC2 and I noticed that it has 45000 mongo connections from our app's server IP. Though in code, there is only one mongo connection getting created at start.
Can anyone help me out here in debugging why it has so many connections?
PS: We use PM2 to restart the server, could it be because of that?

How to connect apollo server to a remote mongo instance of an application deployed with mup

So I have application A and Application B, I want to connect to the mongo instance of application B (through apollo server) which is deployed with mup in another server. By default, you cannot connect to the mongo instance of an application deployed with mup from outside. I tried setting bind_ip=0.0.0.0 in mongo config and set the necessary users and passwords but no luck.
The connections work find if all applications are running in the same server.

MongoDB locally to production

I currently have an app running MongoDB, it works great locally. I am now struggling to find any information if I can host this on my server. Can I ssh into my server and install MongoDB or do I need a service like Mongo Labs?