Not able to connect to mongodb server using mongosh on powershell

Hi Guys ,
Need Help
I am having two servers server A and server B
My mongodb is installed on server B and mongosh tool is also present there
After that I am connecting server A and server B by using powershell.
After connection when I am trying to connecting mongodb by using mongosh tool I am getting connected but immediately connection getting disconnected and I am coming out of test prompt.
Please support if any one having idea regarding this.

Hi @Arshabh_Gujar and welcome to MongoDB community forums!!

Since you have mentioned the post in the Atlas category, can you confirm if the above two servers are two different Atlas servers or these are on-prem MongoDB severs ?
If these are on prem servers, could you help me with the MongoDB version and deployment configuration.

Based on the above statement, it would be helpful if you can help me understand the following:

  1. Is the connection is between two servers is established successfully through powershell?
  2. While you are trying to connect to one of the servers through mongosh, after how much time of inactivity does he see the disconnect happening.
  3. And how frequently does the disconnect happen? Is this always or you is able to successfully establish the connection at some times?

Do you observe any error message while the connection is getting terminated? Can you share the error logs while you are seeing the disconnect ?


Hi Aasawari,
Both servers are hosted on GCP cloud servers.
5985 port is open between server A and server B
where Mongo DB 5.0 is installed in server which is running on win 16 server os.
Mongosh.exe file is also present in server B.
I am connecting server A and server B by powershell using port 5985 after successful connection i am going at the path where mongosh module is present and after that i am trying to connect to that module in powershell by using connection string,
after hitting connection string test prompt is comming and just in fraction of an sec throwing out of the test prompt without any error message.