Ecounter error using heroku for my server.js

hello guys i’ve been working so hard on my project but the last part of it which is deploying to heroku put me into trouble . I’m using Knex and i can’t figure out how to use it with heroku . i’ve also used process.env.DATABASE_URL instead of link in connectionString but it doesn’t work too

const db = knex({
client: 'pg',
connection: {
    connectionString:' postgres://',
    ssl: {
        rejectUnauthorized: false


this is my code can anyone help me ??

@art I see a space character in front of the word postgres. That will mess up your connection string.

You only use the .env file on your local computer. This file should not be pushed up to Github. From your computer you can add database url via the Heroku command line program if you have it installed on you computer like this:

$ heroku config:set DATABASE_URL --app <app_name>

Run Heroku config to make sure it is there. This command will show you the configurations for your app.

$ heroku config --app <app_name>

You can also use the Heroku website to add you DATABASE_URL in the “Setting” page under “Config Vars”.