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”


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.



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