【发布时间】:2021-12-17 09:05:54
【问题描述】:
我需要认真的帮助。一周前我的 Heroku 应用程序崩溃了,我已经排除故障 3 天没有成功。尝试将连接代码更改为 ssl,并对 pg_hba.conf 和 postgresql.conf 文件进行了一些更改,但没有成功。
这是不断出现的错误:
嗨!我需要认真的帮助。一周前我的 Heroku 应用程序崩溃了,我已经排除故障 3 天没有成功。尝试将连接代码更改为 ssl,并对 pg_hba.conf 和 postgresql.conf 文件进行了一些更改,但没有成功。
这是不断出现的错误:
ConnectionError [SequelizeConnectionError]: no pg_hba.conf entry for host "", user "", database "", SSL off
at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:182:24
at Connection.connectingErrorHandler (/app/node_modules/pg/lib/client.js:194:14)
at Connection.emit (events.js:210:5)
at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:134:12)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23) {
name: 'SequelizeConnectionError',
parent: error: no pg_hba.conf entry for host "52.206.229.39", user "pirotuslftnuae", database "d7q6mo0trncmiq", SSL off
at Connection.parseE (/app/node_modules/pg/lib/connection.js:614:13)
at Connection.parseMessage (/app/node_modules/pg/lib/connection.js:413:19)
at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:129:22)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23) {
name: 'error',
length: 167,
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'
},
const db = new Sequelize({
user: "name",
password: "****",
database: "databaseName",
port: 5432,
host: "localhost",
ssl: true,
dialect: 'postgres',
dialectOptions: {
"ssl": {"rejectUnauthorized": false}
}
});
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow rep
# - Connection Settings -
#listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_director`enter code here`ie
【问题讨论】:
-
您显示的 pg_hba 似乎不是您尝试连接的服务器上有效的那个。您可能正在编辑错误的文件,或者在编辑后没有重新加载/重新启动。
-
我使用以下命令访问 pg => sudo nano /etc/postgresql/10/main/pg_hba.conf 和 sudo nano /etc/postgresql/10/main/postgresql.conf 。还有其他方法可以访问吗???我也多次重启了应用程序。
-
需要重启的是数据库,而不是应用服务器。
-
是的,我在 pg 文件中进行更改后重新启动了数据库(postgresql)。
-
sudo service postgresql restart
标签: node.js postgresql heroku