# Cannot connect to external mongodb server

**URL:** <https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734>\
**Category:** General\
**Created:** [March 13, 2025, 1:56pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734 "2025-03-13T13:56:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Wanderer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/martin_wanderer/32/1382_2.png) [@Martin\_Wanderer](https://community.firebasestudio.dev/u/Martin_Wanderer)\
**Post date:** [March 13, 2025, 1:56pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/1 "2025-03-13T13:56:30Z")

</div>

I have a Python project, but I am not able to connect to the database.

The Mongodb Server is working fine, also with other projects.  
Are there any limitations on outgoing connections, when not running a Flask Server?

Failed to connect to MongoDB: No servers found yet, Timeout: 5.0s, Topology Description: \<TopologyDescription id: 67d2e2c7a1f4923fb012aca2, topology\_type: Unknown, servers: [\<ServerDescription (‘XXX.XXX.XXX’, 27017) server\_type: Unknown, rtt: None\>]\>

---

<div class="post-metadata">

**Author:** ![rody](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/rody/32/1488_2.png) [@rody](https://community.firebasestudio.dev/u/rody)\
**Post date:** [March 13, 2025, 5:31pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/2 "2025-03-13T17:31:47Z")

</div>

Have you enabled the public port? That would allow you to connect to the server.

You must also grab the auth token to pass with the request too.

For reference:

> [@Early preview of public ports!](https://community.firebasestudio.dev/t/early-preview-of-public-ports/1911):
>
> Hi everybody - we shipped an early preview of our support for public ports. I recorded a quick video on how you can use it: [[Very early preview of public ports in Project IDX! fire] ](https://www.youtube.com/watch?v=z2l4yH-TwHQ) Please share your feedback. We are going to add some UI next to make it easier to toggle your ports public or private, so stay tuned for that. If you would like to share this on Twitter / X, I also [made a post here](https://x.com/kirupa/status/1834740111789244496). (cc @treeder ) Cheers, Kirupa

---

<div class="post-metadata">

**Author:** ![Martin\_Wanderer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/martin_wanderer/32/1382_2.png) [@Martin\_Wanderer](https://community.firebasestudio.dev/u/Martin_Wanderer)\
**Post date:** [March 13, 2025, 6:20pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/3 "2025-03-13T18:20:35Z")

</div>

The python project on IDX cannot connect to a server that is located somewhere else.  
I don’t have any problems connecting with the same script from my local machine to the mongodb, but on IDX I cannot establish any connection to it.  
I guess it’s not the Backend Port then, correct?

---

<div class="post-metadata">

**Author:** ![rody](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/rody/32/1488_2.png) [@rody](https://community.firebasestudio.dev/u/rody)\
**Post date:** [March 13, 2025, 6:34pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/4 "2025-03-13T18:34:33Z")

</div>

Any ports need to be open on the IDX side to connect to it, but the auth token is important as it will not accept requests without it

---

<div class="post-metadata">

**Author:** ![Martin\_Wanderer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/martin_wanderer/32/1382_2.png) [@Martin\_Wanderer](https://community.firebasestudio.dev/u/Martin_Wanderer)\
**Post date:** [March 13, 2025, 7:12pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/5 "2025-03-13T19:12:12Z")

</div>

I might not understand correctly. Is it something that recently changed on IDX?  
It was working without any problems a while ago. Now it does not work on any project I have.

I have port 9000 as public address, and added 27017 for mongodb (like on the db server).  
But it does not show up in the List of “Backend Ports”, but over the shift+cmd+p (get public ports) it is listed.

Also, I am not sure what you mean by auth token. The Credentials for the URI?mongodb://CREDENTIALS:CREDENTIALS@example.com:27017/

---

<div class="post-metadata">

**Author:** ![rody](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/rody/32/1488_2.png) [@rody](https://community.firebasestudio.dev/u/rody)\
**Post date:** [March 13, 2025, 7:58pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/6 "2025-03-13T19:58:57Z")

</div>

Can you try with the new official MongoDB template?

> **[Sign in - Google Accounts](https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fidx.google.com%2Fnew%2Fmongodb&followup=https%3A%2F%2Fidx.google.com%2Fnew%2Fmongodb&ifkv=ASSHykqzKi25RNFgqT3GGBy0odbm4-VD1VuwymqUBFJbzHIYglUeh0P6Ra6cfNaIFZO6Oo-E3htWzg&passive=1209600&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S-835221345%3A1741895936975182)**

---

<div class="post-metadata">

**Author:** ![Martin\_Wanderer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/martin_wanderer/32/1382_2.png) [@Martin\_Wanderer](https://community.firebasestudio.dev/u/Martin_Wanderer)\
**Post date:** [March 13, 2025, 9:49pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/7 "2025-03-13T21:49:00Z")

</div>

With the template it says “no running server found” at the backend ports section, but I can access with the test db with mongo extention locally.

Could it be related to my account on project.idx?

---

<div class="post-metadata">

**Author:** ![rody](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/rody/32/1488_2.png) [@rody](https://community.firebasestudio.dev/u/rody)\
**Post date:** [March 13, 2025, 10:03pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/8 "2025-03-13T22:03:40Z")

</div>

There should not be a reason why it is account related and either the port is not getting picked up properly in the IDX extension or the wrong port is being used.

Does it work in the command line for you?

---

<div class="post-metadata">

**Author:** ![Martin\_Wanderer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/martin_wanderer/32/1382_2.png) [@Martin\_Wanderer](https://community.firebasestudio.dev/u/Martin_Wanderer)\
**Post date:** [March 14, 2025, 4:27pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/9 "2025-03-14T16:27:36Z")

</div>

No, I cannot get a connection with ping, nc, curl, telnet,… All have a timeout.

---

<div class="post-metadata">

**Author:** ![Phantom21](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/phantom21/32/4572_2.png) [@Phantom21](https://community.firebasestudio.dev/u/Phantom21)\
**Post date:** [March 14, 2025, 6:02pm UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/10 "2025-03-14T18:02:13Z")

</div>

Have you checked the MongoDB Atlas console? Connection timeouts often happen because your workspace IP might have changed and is no longer in the whitelist. Try setting the whitelisted IP to 0.0.0.0/0 (allow access from anywhere) and test again. This should help if the issue is related to IP restrictions, which is common when working in environments where your IP address might change.

---

<div class="post-metadata">

**Author:** ![mohamed\_karim](https://sea2.discourse-cdn.com/flex002/user_avatar/community.firebasestudio.dev/mohamed_karim/32/2712_2.png) [@mohamed\_karim](https://community.firebasestudio.dev/u/mohamed_karim)\
**Post date:** [March 23, 2025, 7:56am UTC](https://community.firebasestudio.dev/t/cannot-connect-to-external-mongodb-server/9734/12 "2025-03-23T07:56:57Z")

</div>

Restart your device and try it
