Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lara135's avatar

DATABASE_URL not working with postgress

Hi, I'm trying to use a laraval based docker image and trying to configure it using the DATABASE_URL setting, however it does not seem to work...

This is the pgsql stuff in config/database.php

		'pgsql' => [
			'driver' => 'pgsql',
			'url' => env('DATABASE_URL'),
			'charset' => 'utf8',
			'timezone' => 'UTC',
			'prefix' => '',
			'prefix_indexes' => true,
			'search_path' => 'public',
			'sslmode' => 'prefer',

And here is a list of the related env variables in the container:

DATABASE_URL=postgres://app:app@lychee_db:5432/app
TIMEZONE=UTC
APP_URL=<not allowed>
PHP_TZ=UTC
DB_CONNECTION=pgsql

Looking at the log it all looks good - no database related error message and seems like datamigrations are running fine.

When I however go to the app url I get the following error:


ErrorException
HTTP 500 Internal Server Error

Undefined array key "database"

 in /var/www/html/Lychee/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php (line 76)
    protected function createSingleConnection(array $config)
    {
        $pdo = $this->createPdoResolver($config);
        return $this->createConnection(
            $config['driver'], $pdo, $config['database'], $config['prefix'], $config
        );
    }
0 likes
0 replies

Please or to participate in this conversation.