1

I have a react app with express server. It's not working on one of my pc(others are fine exact same versions and setup). Problem is even though i can connect to my postgresql db both from terminal and pgadmin interface, neither express server or sequelize can't find/connect it and they don't produce any error. sequelize db:migrate finishes without an error or additional migration/table created message. This leads infinite loading on app but all pending requests eventually fail.

Here is my sequelize config file:

{
  "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
  }
}

and react config in .env and 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 returns this:

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.

1 Answer 1

2

I've been trying to fix this issue and finally found a solution.

If you are using Node v14 just like me, you need to update pg module from npm and that's all

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.