lua-resty-postgres
lua-resty-postgres copied to clipboard
"Not Initialized"
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