【发布时间】:2020-06-23 04:01:01
【问题描述】:
我有一个带有快速服务器的反应应用程序。它不适用于我的一台电脑(其他电脑的版本和设置完全相同)。问题是即使我可以从终端和 pgadmin 界面连接到我的 postgresql 数据库,快递服务器或续集都无法找到/连接它,它们也不会产生任何错误。 sequelize db:migrate 在没有错误或其他迁移/表创建消息的情况下完成。这会导致应用程序无限加载,但所有待处理的请求最终都会失败。
这是我的 sequelize 配置文件:
{
"development": {
"username": "postgres",
"password": "postgres",
"database": "db",
"host": "localhost",
"dialect": "postgres",
"port": 5432
},
"test": {
"username": "postgres",
"password": "postgres",
"database": "db",
"host": "127.0.0.1",
"dialect": "postgres",
"port": 5432
},
"production": {
"username": "postgres",
"password": "postgres",
"database": "db",
"host": "127.0.0.1",
"dialect": "postgres",
"port": 5432
}
}
在 .env 和 express server 中反应配置
.env
DB_PASSWORD=postgres
DB_PORT=5432
DB_DATABASE=db
DB_HOST=localhost
DB_USER=postgres
server.js
const connectionString = `postgresql://${process.env.DB_USER}:${
process.env.DB_PASSWORD
}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_DATABASE}`;
sudo systemctl status postgresql.service 返回:
postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-06-04 20:47:20 +03; 9min ago
Process: 38637 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=0/SUCCESS)
Main PID: 38640 (postgres)
Tasks: 14 (limit: 19096)
Memory: 123.1M
CGroup: /system.slice/postgresql.service
├─38640 /usr/bin/postgres -D /var/lib/postgres/data
├─38644 postgres: checkpointer
├─38645 postgres: background writer
├─38646 postgres: walwriter
├─38647 postgres: autovacuum launcher
├─38648 postgres: stats collector
├─38649 postgres: logical replication launcher
├─38662 postgres: postgres db ::1(42040) idle
├─38834 postgres: postgres db1 ::1(42242) idle
├─38899 postgres: postgres db2 ::1(42352) idle
├─38912 postgres: postgres db3 ::1(42378) idle
├─38949 postgres: postgres db4 ::1(42450) idle
├─38960 postgres: postgres db5 ::1(42470) idle
└─38971 postgres: postgres db6 ::1(42492) idle
Jun 04 20:47:20 archPC postgres[38640]: 2020-06-04 20:47:20.535 +03 [38640] LOG: starting PostgreSQL 12.3 on x8>
Jun 04 20:47:20 archPC postgres[38640]: 2020-06-04 20:47:20.536 +03 [38640] LOG: listening on IPv6 address "::1>
Jun 04 20:47:20 archPC postgres[38640]: 2020-06-04 20:47:20.536 +03 [38640] LOG: listening on IPv4 address "127>
Jun 04 20:47:20 archPC postgres[38640]: 2020-06-04 20:47:20.541 +03 [38640] LOG: listening on Unix socket "/run>
Jun 04 20:47:20 archPC postgres[38643]: 2020-06-04 20:47:20.565 +03 [38643] LOG: database system was shut down >
Jun 04 20:47:20 archPC postgres[38640]: 2020-06-04 20:47:20.573 +03 [38640] LOG: database system is ready to ac>
Jun 04 20:47:20 archPC systemd[1]: Started PostgreSQL database server.
【问题讨论】:
标签: node.js postgresql sequelize.js