# Lumber update - getaddrinfo ENOTFOUND mongodb-01

**URL:** <https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785>\
**Category:** Help me!\
**Tags:** setup\
**Created:** [June 24, 2021, 1:12pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785 "2021-06-24T13:12:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benoit-lng](https://avatars.discourse-cdn.com/v4/letter/b/f14d63/32.png) [@Benoit-lng](https://community.forestadmin.com/u/Benoit-lng)\
**Post date:** [June 24, 2021, 1:12pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/1 "2021-06-24T13:12:08Z")

</div>

Hi team 👋

I’m trying to update my models according the production environment.  
In the machine I installed forest, I use the command  
`lumber update -c ./config/databases.js` in the root folder (where there is my .env file),  
and it returns me the error :

```javascript
✖ Connecting to your database(s)
> Cannot connect to the database due to the following error:
> MongoServerSelectionError: getaddrinfo ENOTFOUND mongodb-01 mongodb-01:27017

```

However, when I can still access to my production data on forestapp.  
So I guess the forest docker is able to login to my production DB and not lumber.

Here my .env

```javascript
FOREST_ENV_SECRET=XYZ
FOREST_AUTH_SECRET=XYZ
DATABASE_URL=mongodb://{{user}}:{{pwd}}@51.280.110.0:27017/twake_console_accounts?authSource=admin
NODE_ENV=production
APPLICATION_URL=https://forest.twake.app
APPLICATION_PORT=5000

CORS_ORIGINS=

DATABASE_SSL=false
# This should be removed in production environment.
#DATABASE_REJECT_UNAUTHORIZED=false

```

## Context

Please provide any relevant information about your setup.

- Package Version: lumber 4.1.10
- Express Version: “~4.17.1”
- Database Dialect: mongodb
- Database Version:
- Project Name: Twake COnsole

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [June 24, 2021, 1:38pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/2 "2021-06-24T13:38:23Z")

</div>

Hello @Benoit-ln 👋, and welcome to the Forest Admin community 🎉

Would that be possible for you to show me what is inside the `./config/databases.js` file?  
It looks like your database on `mongodb-01:27017` is unreachable.

You can debug yourself by directly trying to connect to your mongo db database url this way:

```javascript
const mongodb = require('mongodb');

mongodb.MongoClient.connect(connectionUrl, connectionOptionsMongoClient)
      .then((client) => client.db(options.dbName))
      .catch((error) => this.handleAuthenticationError(error));

```

You can read the documentation of the connect method of MongoClient [here](http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#.connect).

---

<div class="post-metadata">

**Author:** ![Benoit-lng](https://avatars.discourse-cdn.com/v4/letter/b/f14d63/32.png) [@Benoit-lng](https://community.forestadmin.com/u/Benoit-lng)\
**Post date:** [June 24, 2021, 2:10pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/3 "2021-06-24T14:10:19Z")

</div>

Thank you for the welcome 🤗

Here my /config/database.js

```javascript
const path = require('path');

const databaseOptions = {
  useNewUrlParser: true,
  useUnifiedTopology: true,
};

module.exports = [{
  name: 'default',
  modelsDir: path.resolve(__dirname, '../models'),
  connection: {
    url: process.env.DATABASE_URL,
    options: { ...databaseOptions },
  },
}];

```

I tested to connect manually, it worked with this code :

```javascript
const mongodb = require('mongodb');

const connectionUrl = "mongodb://user:pwd@51.280.110.0:27017/twake_console_accounts?authSource=admin";

const connectionOptionsMongoClient = {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  serverSelectionTimeoutMS: 5000,
  family:4
};

const options = {
dbName : "twake_console_accounts"
}
mongodb.MongoClient.connect(connectionUrl, connectionOptionsMongoClient)
      .then((client) => {
   const db = client.db(options.dbName);
const collection = db.collection('users');
   collection.find({}).toArray(function(err, docs) {
    console.log('Found the following records');
    console.log(docs);
        });
}).catch((error) => console.log(error));

```

It’s why I don’t understand. When forest has to request my db, it is working, but not lumber-cli 🤔

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [June 24, 2021, 3:02pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/4 "2021-06-24T15:02:53Z")

</div>

Quick question, does your host is equal to `51.280.110.0` or `mongodb-01`?

From what I understand, it should be `51.280.110.0`.  
Can you try by modifying your code with:

```javascript
const connectionUrl = process.env.DATABASE_URL;

```

I don’t get why the error trace deals with `mongodb-01` host…

---

<div class="post-metadata">

**Author:** ![Benoit-lng](https://avatars.discourse-cdn.com/v4/letter/b/f14d63/32.png) [@Benoit-lng](https://community.forestadmin.com/u/Benoit-lng)\
**Post date:** [June 24, 2021, 3:16pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/5 "2021-06-24T15:16:20Z")

</div>

Yes, my db is hosted on 51.280.110.0.

I updated the code to use the env file and it worked well 😕

```javascript
mongodb = require('mongodb');

const databaseOptions = {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  serverSelectionTimeoutMS: 5000,
  family:4
};

console.log(process.env.DATABASE_URL);
mongodb.MongoClient.connect(process.env.DATABASE_URL, databaseOptions)
      .then((client) => {
   const db = client.db();
const collection = db.collection('users');
   collection.find({}).toArray(function(err, docs) {
    console.log('Found the following records');
    console.log(docs);
        });
}).catch((error) => console.log(error));

```

---

<div class="post-metadata">

**Author:** ![Guillaume\_Cisco](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaume_cisco/32/918_2.png) [@Guillaume\_Cisco](https://community.forestadmin.com/u/Guillaume_Cisco)\
**Post date:** [June 24, 2021, 3:22pm UTC](https://community.forestadmin.com/t/lumber-update-getaddrinfo-enotfound-mongodb-01/2785/6 "2021-06-24T15:22:05Z")

</div>

The lumber code is open source and you can check your code against the reference [here](https://github.com/ForestAdmin/lumber/blob/master/services/database.js#L37)

Do you see any differences between your test and the lumber code?

Let me know 😉
