Setting the DATABASE_URL

Hi People,

probably a very stupid question (I’m very new to chatbots and botpress), but I have a bot deployed to Heroku and now I want to deploy Heroku Postgres. I don’t really understand where I have to save the environmental variable DATABASE_URL. In the docs it says I should save it as an .env file, but where?

Thanks for the help

Hi @Nico

The .env file should be in the same directory as the bp executable file

@spgin Thanks for your answer. I have meanwhile followed the instruction in the docs, where I wanted to change my existing SQLite DB with a Heroku Postgres to an application that I have previously deployed to Heroku, like so:

# Get a free Postgres database
heroku addons:create heroku-postgresql --app $APP_NAME

# Tell Botpress to use Postgres
heroku config:set DATABASE=postgres --app $APP_NAME

After doing this, I get the following error in the Heroku Logs

2021-04-06T13:55:18.460222+00:00 app[web.1]: Error starting botpress
2021-04-06T13:55:18.471930+00:00 app[web.1]: error: no pg_hba.conf entry for host "3.89.70.205", user "XXXX", database "XXXX", SSL off
2021-04-06T13:55:18.471932+00:00 app[web.1]: at Connection.parseE (/snapshot/build-linux/node_modules/pg/lib/connection.js:601:11)
2021-04-06T13:55:18.471933+00:00 app[web.1]: at Connection.parseMessage (/snapshot/build-linux/node_modules/pg/lib/connection.js:398:19)
2021-04-06T13:55:18.471933+00:00 app[web.1]: at Socket.<anonymous> (/snapshot/build-linux/node_modules/pg/lib/connection.js:120:22)
2021-04-06T13:55:18.471934+00:00 app[web.1]: at Socket.emit (events.js:315:20)
2021-04-06T13:55:18.471934+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2021-04-06T13:55:18.471935+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:271:9)
2021-04-06T13:55:18.471935+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:212:10)
2021-04-06T13:55:18.471936+00:00 app[web.1]: at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
2021-04-06T13:55:18.471937+00:00 app[web.1]: length: 165,
2021-04-06T13:55:18.471937+00:00 app[web.1]: severity: 'FATAL',
2021-04-06T13:55:18.471937+00:00 app[web.1]: code: '28000',
2021-04-06T13:55:18.471938+00:00 app[web.1]: detail: undefined,
2021-04-06T13:55:18.471938+00:00 app[web.1]: hint: undefined,
2021-04-06T13:55:18.471938+00:00 app[web.1]: position: undefined,
2021-04-06T13:55:18.471939+00:00 app[web.1]: internalPosition: undefined,
2021-04-06T13:55:18.471939+00:00 app[web.1]: internalQuery: undefined,
2021-04-06T13:55:18.471939+00:00 app[web.1]: where: undefined,
2021-04-06T13:55:18.471940+00:00 app[web.1]: schema: undefined,
2021-04-06T13:55:18.471940+00:00 app[web.1]: table: undefined,
2021-04-06T13:55:18.471940+00:00 app[web.1]: column: undefined,
2021-04-06T13:55:18.471941+00:00 app[web.1]: dataType: undefined,
2021-04-06T13:55:18.471941+00:00 app[web.1]: constraint: undefined,
2021-04-06T13:55:18.471941+00:00 app[web.1]: file: 'auth.c',
2021-04-06T13:55:18.471942+00:00 app[web.1]: line: '496',
2021-04-06T13:55:18.471942+00:00 app[web.1]: routine: 'ClientAuthentication'
2021-04-06T13:55:18.471943+00:00 app[web.1]: }
2021-04-06T13:55:18.471951+00:00 app[web.1]: no pg_hba.conf entry for host "3.89.70.205", user "XXXX", database "XXXX", SSL off
2021-04-06T13:55:18.472028+00:00 app[web.1]: ---STACK---
2021-04-06T13:55:18.472146+00:00 app[web.1]: error: no pg_hba.conf entry for host "3.89.70.205", user "XXXX", database "XXXX", SSL off
2021-04-06T13:55:18.472147+00:00 app[web.1]: at Connection.parseE (/snapshot/build-linux/node_modules/pg/lib/connection.js:601:11)
2021-04-06T13:55:18.472147+00:00 app[web.1]: at Connection.parseMessage (/snapshot/build-linux/node_modules/pg/lib/connection.js:398:19)
2021-04-06T13:55:18.472147+00:00 app[web.1]: at Socket.<anonymous> (/snapshot/build-linux/node_modules/pg/lib/connection.js:120:22)
2021-04-06T13:55:18.472148+00:00 app[web.1]: at Socket.emit (events.js:315:20)
2021-04-06T13:55:18.472148+00:00 app[web.1]: at addChunk (_stream_readable.js:295:12)
2021-04-06T13:55:18.472149+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:271:9)
2021-04-06T13:55:18.472149+00:00 app[web.1]: at Socket.Readable.push (_stream_readable.js:212:10)
2021-04-06T13:55:18.472149+00:00 app[web.1]: at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
2021-04-06T13:55:30.263440+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-04-06T13:55:30.343651+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-04-06T13:55:30.525992+00:00 heroku[web.1]: Process exited with status 137

Afterwards the I can’t reach the deployed Botpress Server anymore… any idead why?

Edit: When I look at my Heroku environmental variables, there is no DATABASE_URL only HEROKU_POSTGRESQL_AMBER_URL.

When I try to add the DATABASE_URL everything crashes again.

Solution

Turn out that the problem was that the free version of Heroku does not use SSL, which is required. Switch to another provider and it works fine.