Skip to content

Bug: [Postgre] Unable to connect to the database #8771

@warcooft

Description

@warcooft

PHP Version

8.3

CodeIgniter4 Version

4.5.0

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

cli-server (PHP built-in webserver)

Database

PostgreSQL 15.4

What happened?

I have followed the documentation regarding database configuration. https://codeigniter.com/user_guide/datab...tion.html#

here my db config:

public array $default = [
        'DSN'          => 'Postgre://username:password@hostname:5432/database?charset=utf8&connect_timeout=5&sslmode=1',
        'hostname'     => 'localhost',
        'username'     => 'postgres',
        'password'     => '123456',
        'database'     => 'playground_db',
        'DBDriver'     => 'Postgre',
        'DBPrefix'     => '',
        'pConnect'     => false,
        'DBDebug'      => true,
        'charset'      => 'utf8mb4',
        'DBCollat'     => 'utf8mb4_general_ci',
        'swapPre'      => '',
        'encrypt'      => false,
        'compress'     => false,
        'strictOn'     => false,
        'failover'     => [],
        'port'         => 5432,
        'numberNative' => false,
        'dateFormat'   => [
            'date'     => 'Y-m-d',
            'datetime' => 'Y-m-d H:i:s',
            'time'     => 'H:i:s',
        ],
    ];

and then i got this error:

Unable to connect to the database. Main connection [Postgre]: pg_connect(): Unable to connect to PostgreSQL server: invalid sslmode value: "1"

Here details:
https://postimg.cc/bGf6Kmfw

Steps to Reproduce

I have applied the above configuration to the .env file in Codeigniter 4.4.8 and it works fine, but why doesn't it work in Codeigniter 4.5.0? Previously I tried to apply it in .env exactly with version 4.4.8 but it didn't work. Lastly, I configured it in the Config\Database.php file and it also didn't work.

Expected Output

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions