相关疑难解决方法(0)

SequelizeConnectionError:自签名证书

我正在尝试连接到我在 Heroku 中设置的 PostgreSQL 数据库。

const { Sequelize, DataTypes, Model } = require("sequelize");

// DB Configuration
const sequelize = new Sequelize({
  database: "[wont'd show db]",
  username: "[won't show username]",
  password: "[won't show password]",
  host: "ec2-54-221-195-148.compute-1.amazonaws.com",
  port: 5432,
  dialect: "postgres",
  dialectOptions: {
    ssl: true,
  },
});

Run Code Online (Sandbox Code Playgroud)

这就是我得到的输出:

SequelizeConnectionError:自签名证书

javascript postgresql backend express

27
推荐指数
2
解决办法
8934
查看次数

NodeJs postgresql 连接失败

  • 我尝试从 nodeJs 连接到 rds postgresql版本 12,如下所述。它工作完全正常,没有任何问题。

    const config = {
    
        user: process.env.PG_DB_USERNAME,
        password: process.env.PG_DB_PASSWORD,
        database: process.env.PG_DB_NAME,
        host: process.env.PG_DB_HOST,
        port: process.env.PG_DB_PORT,
     }
       const pool = new Pool(config)
    
    Run Code Online (Sandbox Code Playgroud)

当我们使用 postgresql 15.2 版 从节点 Js 连接时,我们最终遇到了以下错误。

错误

{"length":181,"name":"error","severity":"FATAL","code":"28000","file":"auth.c","line":"543","routine":"ClientAuthentication","level":"error","timestamp":"2023-06-19T14:13:33.294Z"}

[ERROR] error: no pg_hba.conf entry for host "XXXXX", user "test", database "testdb", no encryption

at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:526:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead …
Run Code Online (Sandbox Code Playgroud)

postgresql amazon-rds node.js pg

5
推荐指数
1
解决办法
2434
查看次数

Postgrex - 主机"xxx.xxx.xxx.xxx"没有pg_hba.conf条目

我有一个单独托管的Postgres数据库,我正在尝试使用我的Phoenix应用程序.我的prod配置是:

config :my_app, MyApp.Repo,
  adapter: Ecto.Adapters.Postgres,
  url: "postgres://username:password@myhost:5432/my_database",
  size: 20 
Run Code Online (Sandbox Code Playgroud)

当我的应用程序托管在Heroku上时,这工作正常,但是因为我已经将它移动到VPS,我不断收到此错误:

17:07:13.665 [info] GET /subjects
17:07:13.707 [info] Processing by MyApp.SubjectController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser, :authorize]
17:07:13.951 [error] GenServer #PID<0.515.0> terminating
** (exit) %Postgrex.Error{message: nil, postgres: %{code: :invalid_authorization_specification, file: "auth.c", line: "474", message: "no pg_hba.conf entry for host \"xxx.xxx.xxx.xxx\", user \"username\", database \"my_database\", SSL off", pg_code: "28000", routine: "ClientAuthentication", severity: "FATAL"}}
17:07:13.970 [info] Sent 500 in 305ms
17:07:13.972 [error] #PID<0.513.0> running MyApp.Endpoint terminated
Server: xxx.xxx.xxx.xxx:80 (http)
Request: …
Run Code Online (Sandbox Code Playgroud)

postgresql ecto phoenix-framework

4
推荐指数
1
解决办法
3697
查看次数