lua-resty-postgres icon indicating copy to clipboard operation
lua-resty-postgres copied to clipboard

"Not Initialized"

Open 619 opened this issue 1 year ago • 0 comments

Even with hardcoded env variables, the ok variable returns nil and the err variable returns "not initialized". Firewall disabled, and can successfully access the postgresql database with psql from the digitalocean droplet instance.

local pg = postgres:new() pg:set_timeout(3000)

local ok, err = pg:connect{
    host = process.env.POSTGRESQL_DATABASE_HOST_1,
    port = process.env.POSTGRESQL_DATABASE_PORT_1,
    database = process.env.POSTGRESQL_DATABASE_NAME_1,
    user = process.env.POSTGRESQL_DATABASE_USERNAME_1,
    password = process.env.POSTGRESQL_DATABASE_PASSWORD_1
}

if not ok then
    ngx.log(ngx.ERR, "Failed to connect to the database: ", err)
    return nil
end

619 avatar Jul 05 '23 19:07 619