![](/img/trans.png)
[英]Rails: Migrating to Auth0 while retaining postgres records and associations
[英]how to connect postgres database with Auth0
当我用Auth0连接heroku postgres数据库时,我遇到了以下错误。
could not connect to postgres db { [error: no pg_hba.conf entry for host "XXXXXXXX", user "XXXXXX", database "XXXXXX", SSL off]
name: 'error',
length: 161,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '496',
routine: 'ClientAuthentication' }
[error] 28000 - undefined
我正在使用Auth0,因此请在下面的auth0代码中找到heroku数据库详细信息和URL。
configuration.config_file = "postgres://username:password@host:port/DB_name"
function login (email, password, callback) {
var conString = configuration.config_file;
postgres(conString, function (err, client) {
if (err) {
console.log('could not connect to postgres db', err);
return callback(err);
}
});
}
尝试将'?ssl = true'添加到您的conString中。 Heroku需要通过SSL访问以进行远程连接。 有关详细信息,请参见https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-node-js (在“远程连接”下)。
您在此处编写的代码在Auth0(在云中)中运行。 这意味着您需要使用Auth0可以连接的主机名或IP地址。
如果您使用主机名(如DBSERVER01
或IP地址(如10.10.5.1
这些仅在您的网络中可用,而auth0将无法访问它们。
确保使用网络的公共IP地址(例如45.19.3.29
)或面向公共的主机名(例如mydb01.mycompany.com
)。
从ubuntu网站上查看此文档 。 它说明了如何在本地安装postgres数据库。
安装postgres之后,您将需要创建一个用户并为其提供正确的身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.