Strapi Issue “Error while running command develop: Could not load js config file /app/config/env/production/database.js: Cannot read property ‘charAt’ of undefined”

Photo by NeONBRAND on Unsplash


I struggle with this error for a little bit. When I finally figured out that this error is in relation to a loading problem of environment variables. Let take a look into the indicated “database.js” file.

const { parse } = require(“pg-connection-string”);module.exports = ({ env }) => {
const { host, port, database, user, password } = parse(env(“DATABASE_URL”));
return {
defaultConnection: “default”,
connections: {
default: {
connector: “bookshelf”,
settings: {
client: “postgres”,
username: user,
ssl: { rejectUnauthorized: false }
options: {
ssl: false

On the bold market part we see that an environment variable DATABASE_URL is loaded. Now we need to check if the variable is set in our system.

Therefore execute(printenv):

MacBook-Pro cms % printenv
XPC_FLAGS=0x0TERM_PROGRAM_VERSION=433TERM_PROGRAM=Apple_TerminalXPC_SERVICE_NAME=0TERM_SESSION_ID=D6553DCC-0241-4914-9348-B71F225AE395TERM=xterm-256colorMacBook-Pro cms %

we don’t see any variable for the DATABASE_URL.


In a Dockerfile you can use:

ENV DATABASE_URL=postgres://kauznionjswwod:d0c9ae...

In a system environment use:

export DATABASE_URL=postgres://kauznionjswwod:d0c9ae

This should fix the error for you. My problem was that i was setting the wrong variable name. So… be smart and always double-check if you set everything correctly. You can check it with the printenv command.

Happy coding.




If you like my work or have question contact me.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Unit Testing for REST APIs in Go

CHS React Meetup April 1st

Web Development Weekly Issue 29

What is Express, and how can we use it?

Generate Temporary (One Time) Passwords without Data Base

Developing at DevTools and Hot Reload Fault, After That, What Can You Do?

Starting at Square One: Creating a Checkerboard through Canvas and Javascript

The best features of the latest Javascript version since ES6

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


If you like my work or have question contact me.

More from Medium

Console log use different ways



Magento Image Optimization Advice and Tools

File Transfer Resume with FTP & SFTP

Choose the Resume option in your FTP client.