# Cant connect to mongodb atlas

**URL:** <https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418>\
**Category:** Help\
**Created:** [December 14, 2022, 2:54am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418 "2022-12-14T02:54:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 14, 2022, 2:54am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/1 "2022-12-14T02:54:00Z")

</div>

`#11 24.79 2022-12-14T02:35:50.678Z INFO 82 --- [ngodb.net:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server ac-19e3r20-shard-00-01.naeeug3.mongodb.net:27017` `#11 24.79` `#11 24.79 com.mongodb.MongoSocketReadException: Prematurely reached end of stream`

---

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 14, 2022, 2:55am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/2 "2022-12-14T02:55:16Z")

</div>

I need to know the ip of the kubernetes node to allow the connection in mongodb atlas

---

<div class="post-metadata">

**Author:** ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)\
**Post date:** [December 14, 2022, 3:21am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/3 "2022-12-14T03:21:37Z")

</div>

Hey @rubengarcia0510 , welcome to our community!

Where are you running your remote development environment?

We don’t publish the outbound IPs of [https://cloud.okteto.com](https://cloud.okteto.com), since they are constantly changing.  
Due to their cost, Static outbound IPs are something we only offer in the [Scale and Enterprise tiers](https://www.okteto.com/pricing/?plan=SaaS) of our SaaS product.

To use MongoDB Atlas with [https://cloud.okteto.com](https://cloud.okteto.com), you’ll need to either allow all IPs or, even better, look for another security model.

---

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 14, 2022, 2:11pm UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/4 "2022-12-14T14:11:32Z")

</div>

There are a way to use a database in okteto?

---

<div class="post-metadata">

**Author:** ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)\
**Post date:** [December 14, 2022, 7:11pm UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/5 "2022-12-14T19:11:18Z")

</div>

Yes, you can deploy any container-based database as part of your development environment. We have examples on [GitHub - okteto/samples: Learn how to develop with Okteto](https://github.com/okteto/samples) that show how to do it for different stacks and application deployment manifests.

---

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 14, 2022, 10:55pm UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/6 "2022-12-14T22:55:25Z")

</div>

I deployed this container

 ![image.png](https://us1.discourse-cdn.com/flex019/uploads/okteto/original/1X/6dd608030ef44ed5b940844752c38c208452291d.png)

What do you think is the url to connect to the mongodb database?

Thank you

Ruben Garcia

---

<div class="post-metadata">

**Author:** ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)\
**Post date:** [December 14, 2022, 10:59pm UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/7 "2022-12-14T22:59:39Z")

</div>

To connect from another container on the same namespace, the format would be:

```auto
protocol://serviceName:port

```

In the case of the example, assuming you are using default configurations for MongoDB, it would be:

```auto
mongodb://$username:$password@mongodb:27017

```

---

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 14, 2022, 11:12pm UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/8 "2022-12-14T23:12:47Z")

</div>

And to connect to other namespace?

---

<div class="post-metadata">

**Author:** ![rubengarcia0510](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/rubengarcia0510/32/251_2.png) [@rubengarcia0510](https://community.okteto.com/u/rubengarcia0510)\
**Post date:** [December 15, 2022, 1:39am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/9 "2022-12-15T01:39:26Z")

</div>

Ok, as you told me, I was deployed the database in the same namespace of the backend, but it’s still failing the connection to the mongodb database

 ![image.png](https://us1.discourse-cdn.com/flex019/uploads/okteto/original/1X/944d009f7b5719f6f821de88c4b43bf423fe6e74.png)

---

<div class="post-metadata">

**Author:** ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)\
**Post date:** [December 15, 2022, 1:42am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/10 "2022-12-15T01:42:54Z")

</div>

> [@rubengarcia0510](#):
>
> And to connect to other namespace?

To connect to other namespace, you need to use `$serviceName.$namespace` as the host name.

---

<div class="post-metadata">

**Author:** ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)\
**Post date:** [December 15, 2022, 1:46am UTC](https://community.okteto.com/t/cant-connect-to-mongodb-atlas/418/11 "2022-12-15T01:46:10Z")

</div>

> [@rubengarcia0510](#):
>
> Ok, as you told me, I was deployed the database in the same namespace of the backend, but it’s still failing the connection to the mongodb database

Is hard to tell what’s going on without knowing how you are connecting to mongodb. Maybe try different credentials, or setting up the database on the connection string?

What I recommend you do is to do `okteto up` into the backendReactive service that you are developing… That will give you a remote terminal into your service. You can use that to iterate on your code until you figure out how to correctly connect to the DB, or if there are other issues around. [This is a good way](https://www.okteto.com/docs/using-dev-envs/) to get started with `okteto up`.
