Planka can't connect to database #102

Closed
opened 2026-02-04 17:12:01 +03:00 by OVERLORD · 14 comments
Owner

Originally created by @Jummit on GitHub (May 12, 2021).

I followed the installation instructions on my new Arch machine, but I get this error in the log:

node:internal/process/promises:245
planka_1    |           triggerUncaughtException(err, true /* fromPromise */);
planka_1    |           ^
planka_1    | 
planka_1    | Error: connect EHOSTUNREACH 172.16.0.2:5432
planka_1    |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1138:16) {
planka_1    |   errno: -113,
planka_1    |   code: 'EHOSTUNREACH',
planka_1    |   syscall: 'connect',
planka_1    |   address: '172.16.0.2',
planka_1    |   port: 5432
planka_1    | }
planka_1    | Tried 16 times. Waiting 5 seconds...

The database seems to have started up correctly:

postgres_1  | 2021-05-12 13:58:44.062 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2021-05-12 13:58:44.062 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2021-05-12 13:58:44.065 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2021-05-12 13:58:44.075 UTC [50] LOG:  database system was shut down at 2021-05-12 13:58:43 UTC
postgres_1  | 2021-05-12 13:58:44.078 UTC [1] LOG:  database system is ready to accept connections
Originally created by @Jummit on GitHub (May 12, 2021). I followed the installation instructions on my new Arch machine, but I get this error in the log: ``` node:internal/process/promises:245 planka_1 | triggerUncaughtException(err, true /* fromPromise */); planka_1 | ^ planka_1 | planka_1 | Error: connect EHOSTUNREACH 172.16.0.2:5432 planka_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1138:16) { planka_1 | errno: -113, planka_1 | code: 'EHOSTUNREACH', planka_1 | syscall: 'connect', planka_1 | address: '172.16.0.2', planka_1 | port: 5432 planka_1 | } planka_1 | Tried 16 times. Waiting 5 seconds... ``` The database seems to have started up correctly: ``` postgres_1 | 2021-05-12 13:58:44.062 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres_1 | 2021-05-12 13:58:44.062 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres_1 | 2021-05-12 13:58:44.065 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2021-05-12 13:58:44.075 UTC [50] LOG: database system was shut down at 2021-05-12 13:58:43 UTC postgres_1 | 2021-05-12 13:58:44.078 UTC [1] LOG: database system is ready to accept connections ```
Author
Owner

@nickbe commented on GitHub (May 13, 2021):

EHOSTUNREACH probably means that the host cannot be found. Our own database runs on localhost and localhost is used for the connection. So I would probably change 172.16.0.2 to localhost

@nickbe commented on GitHub (May 13, 2021): EHOSTUNREACH probably means that the host cannot be found. Our own database runs on localhost and localhost is used for the connection. So I would probably change 172.16.0.2 to localhost
Author
Owner

@Jummit commented on GitHub (May 13, 2021):

Where do I change the address of the database? I have this in my docker-compose.yml:
- DATABASE_URL=postgresql://postgres@postgres/planka

@Jummit commented on GitHub (May 13, 2021): Where do I change the address of the database? I have this in my `docker-compose.yml`: `- DATABASE_URL=postgresql://postgres@postgres/planka`
Author
Owner

@BHWarrior commented on GitHub (May 14, 2021):

I have the same problem and don't know how to solve this. My full log:

Creating network "planka_default" with the default driver
Creating planka_postgres_1 ... done
Creating planka_planka_1   ... done
Attaching to planka_postgres_1, planka_planka_1
postgres_1  | ********************************************************************************
postgres_1  | WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow
postgres_1  |          anyone with access to the Postgres port to access your database without
postgres_1  |          a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
postgres_1  |          documentation about "trust":
postgres_1  |          https://www.postgresql.org/docs/current/auth-trust.html
postgres_1  |          In Docker's default configuration, this is effectively any other
postgres_1  |          container on the same system.
postgres_1  |
postgres_1  |          It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
postgres_1  |          it with "-e POSTGRES_PASSWORD=password" instead to set a password in
postgres_1  |          "docker run".
postgres_1  | ********************************************************************************
postgres_1  | The files belonging to this database system will be owned by user "postgres".
postgres_1  | This user must also own the server process.
postgres_1  |
postgres_1  | The database cluster will be initialized with locale "en_US.utf8".
postgres_1  | The default database encoding has accordingly been set to "UTF8".
postgres_1  | The default text search configuration will be set to "english".
postgres_1  |
postgres_1  | Data page checksums are disabled.
postgres_1  |
postgres_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres_1  | creating subdirectories ... ok
postgres_1  | selecting dynamic shared memory implementation ... posix
postgres_1  | selecting default max_connections ... 100
postgres_1  | selecting default shared_buffers ... 128MB
postgres_1  | selecting default time zone ... UTC
postgres_1  | creating configuration files ... ok
postgres_1  | running bootstrap script ... ok
postgres_1  | performing post-bootstrap initialization ... sh: locale: not found
postgres_1  | 2021-05-14 01:32:27.137 UTC [33] WARNING:  no usable system locales were found
planka_1    | node:internal/process/promises:245
planka_1    |           triggerUncaughtException(err, true /* fromPromise */);
planka_1    |           ^
planka_1    |
planka_1    | Error: connect ECONNREFUSED 192.168.80.2:5432
planka_1    |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1138:16) {
planka_1    |   errno: -111,
planka_1    |   code: 'ECONNREFUSED',
planka_1    |   syscall: 'connect',
planka_1    |   address: '192.168.80.2',
planka_1    |   port: 5432
planka_1    | }
planka_1    | Tried 1 times. Waiting 5 seconds...
postgres_1  | ok
postgres_1  | syncing data to disk ... ok
postgres_1  |
postgres_1  |
postgres_1  | Success. You can now start the database server using:
postgres_1  |
postgres_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres_1  |
postgres_1  | initdb: warning: enabling "trust" authentication for local connections
postgres_1  | You can change this by editing pg_hba.conf or using the option -A, or
postgres_1  | --auth-local and --auth-host, the next time you run initdb.
postgres_1  | waiting for server to start....2021-05-14 01:32:28.329 UTC [38] LOG:  starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
postgres_1  | 2021-05-14 01:32:28.332 UTC [38] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2021-05-14 01:32:28.343 UTC [39] LOG:  database system was shut down at 2021-05-14 01:32:27 UTC
postgres_1  | 2021-05-14 01:32:28.348 UTC [38] LOG:  database system is ready to accept connections
postgres_1  |  done
postgres_1  | server started
postgres_1  | CREATE DATABASE
postgres_1  |
postgres_1  |
postgres_1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres_1  |
postgres_1  | waiting for server to shut down....2021-05-14 01:32:28.650 UTC [38] LOG:  received fast shutdown request
postgres_1  | 2021-05-14 01:32:28.655 UTC [38] LOG:  aborting any active transactions
postgres_1  | 2021-05-14 01:32:28.659 UTC [38] LOG:  background worker "logical replication launcher" (PID 45) exited with exit code 1
postgres_1  | 2021-05-14 01:32:28.660 UTC [40] LOG:  shutting down
postgres_1  | 2021-05-14 01:32:28.682 UTC [38] LOG:  database system is shut down
postgres_1  |  done
postgres_1  | server stopped
postgres_1  |
postgres_1  | PostgreSQL init process complete; ready for start up.
postgres_1  |
postgres_1  | 2021-05-14 01:32:28.788 UTC [1] LOG:  starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
postgres_1  | 2021-05-14 01:32:28.788 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2021-05-14 01:32:28.788 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2021-05-14 01:32:28.795 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2021-05-14 01:32:28.803 UTC [52] LOG:  database system was shut down at 2021-05-14 01:32:28 UTC
postgres_1  | 2021-05-14 01:32:28.809 UTC [1] LOG:  database system is ready to accept connections
planka_1    | debug: Detected Sails environment is "production", but NODE_ENV is `undefined`.
planka_1    | debug: Automatically setting the NODE_ENV environment variable to "production".
planka_1    | debug:
planka_1    | debug: -------------------------------------------------------
planka_1    | debug: :: Fri May 14 2021 01:32:35 GMT+0000 (Coordinated Universal Time)
planka_1    | debug: Environment : production
planka_1    | debug: Port        : 1337
planka_1    | debug: `-------------------------------------------------------
@BHWarrior commented on GitHub (May 14, 2021): I have the same problem and don't know how to solve this. My full log: ``` Creating network "planka_default" with the default driver Creating planka_postgres_1 ... done Creating planka_planka_1 ... done Attaching to planka_postgres_1, planka_planka_1 postgres_1 | ******************************************************************************** postgres_1 | WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow postgres_1 | anyone with access to the Postgres port to access your database without postgres_1 | a password, even if POSTGRES_PASSWORD is set. See PostgreSQL postgres_1 | documentation about "trust": postgres_1 | https://www.postgresql.org/docs/current/auth-trust.html postgres_1 | In Docker's default configuration, this is effectively any other postgres_1 | container on the same system. postgres_1 | postgres_1 | It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace postgres_1 | it with "-e POSTGRES_PASSWORD=password" instead to set a password in postgres_1 | "docker run". postgres_1 | ******************************************************************************** postgres_1 | The files belonging to this database system will be owned by user "postgres". postgres_1 | This user must also own the server process. postgres_1 | postgres_1 | The database cluster will be initialized with locale "en_US.utf8". postgres_1 | The default database encoding has accordingly been set to "UTF8". postgres_1 | The default text search configuration will be set to "english". postgres_1 | postgres_1 | Data page checksums are disabled. postgres_1 | postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok postgres_1 | creating subdirectories ... ok postgres_1 | selecting dynamic shared memory implementation ... posix postgres_1 | selecting default max_connections ... 100 postgres_1 | selecting default shared_buffers ... 128MB postgres_1 | selecting default time zone ... UTC postgres_1 | creating configuration files ... ok postgres_1 | running bootstrap script ... ok postgres_1 | performing post-bootstrap initialization ... sh: locale: not found postgres_1 | 2021-05-14 01:32:27.137 UTC [33] WARNING: no usable system locales were found planka_1 | node:internal/process/promises:245 planka_1 | triggerUncaughtException(err, true /* fromPromise */); planka_1 | ^ planka_1 | planka_1 | Error: connect ECONNREFUSED 192.168.80.2:5432 planka_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1138:16) { planka_1 | errno: -111, planka_1 | code: 'ECONNREFUSED', planka_1 | syscall: 'connect', planka_1 | address: '192.168.80.2', planka_1 | port: 5432 planka_1 | } planka_1 | Tried 1 times. Waiting 5 seconds... postgres_1 | ok postgres_1 | syncing data to disk ... ok postgres_1 | postgres_1 | postgres_1 | Success. You can now start the database server using: postgres_1 | postgres_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start postgres_1 | postgres_1 | initdb: warning: enabling "trust" authentication for local connections postgres_1 | You can change this by editing pg_hba.conf or using the option -A, or postgres_1 | --auth-local and --auth-host, the next time you run initdb. postgres_1 | waiting for server to start....2021-05-14 01:32:28.329 UTC [38] LOG: starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit postgres_1 | 2021-05-14 01:32:28.332 UTC [38] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2021-05-14 01:32:28.343 UTC [39] LOG: database system was shut down at 2021-05-14 01:32:27 UTC postgres_1 | 2021-05-14 01:32:28.348 UTC [38] LOG: database system is ready to accept connections postgres_1 | done postgres_1 | server started postgres_1 | CREATE DATABASE postgres_1 | postgres_1 | postgres_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* postgres_1 | postgres_1 | waiting for server to shut down....2021-05-14 01:32:28.650 UTC [38] LOG: received fast shutdown request postgres_1 | 2021-05-14 01:32:28.655 UTC [38] LOG: aborting any active transactions postgres_1 | 2021-05-14 01:32:28.659 UTC [38] LOG: background worker "logical replication launcher" (PID 45) exited with exit code 1 postgres_1 | 2021-05-14 01:32:28.660 UTC [40] LOG: shutting down postgres_1 | 2021-05-14 01:32:28.682 UTC [38] LOG: database system is shut down postgres_1 | done postgres_1 | server stopped postgres_1 | postgres_1 | PostgreSQL init process complete; ready for start up. postgres_1 | postgres_1 | 2021-05-14 01:32:28.788 UTC [1] LOG: starting PostgreSQL 13.2 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit postgres_1 | 2021-05-14 01:32:28.788 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 postgres_1 | 2021-05-14 01:32:28.788 UTC [1] LOG: listening on IPv6 address "::", port 5432 postgres_1 | 2021-05-14 01:32:28.795 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" postgres_1 | 2021-05-14 01:32:28.803 UTC [52] LOG: database system was shut down at 2021-05-14 01:32:28 UTC postgres_1 | 2021-05-14 01:32:28.809 UTC [1] LOG: database system is ready to accept connections planka_1 | debug: Detected Sails environment is "production", but NODE_ENV is `undefined`. planka_1 | debug: Automatically setting the NODE_ENV environment variable to "production". planka_1 | debug: planka_1 | debug: ------------------------------------------------------- planka_1 | debug: :: Fri May 14 2021 01:32:35 GMT+0000 (Coordinated Universal Time) planka_1 | debug: Environment : production planka_1 | debug: Port : 1337 planka_1 | debug: `------------------------------------------------------- ```
Author
Owner

@meltyshev commented on GitHub (May 14, 2021):

@benyhirmansyah, it looks like everything is ok in your log

@meltyshev commented on GitHub (May 14, 2021): @benyhirmansyah, it looks like everything is ok in your log
Author
Owner

@meltyshev commented on GitHub (May 14, 2021):

@Jummit, do you use the default docker-compose config?

@meltyshev commented on GitHub (May 14, 2021): @Jummit, do you use the default docker-compose config?
Author
Owner

@BHWarrior commented on GitHub (May 14, 2021):

@benyhirmansyah, it looks like everything is ok in your log

But when I try curl http://127.0.0.1:3000, I got this:

curl: (56) Recv failure: Connection reset by peer

Also, when I tried on browser, I got 502 Bad Gateway on nginx response.

@BHWarrior commented on GitHub (May 14, 2021): > @benyhirmansyah, it looks like everything is ok in your log But when I try `curl http://127.0.0.1:3000`, I got this: `curl: (56) Recv failure: Connection reset by peer` Also, when I tried on browser, I got 502 Bad Gateway on nginx response.
Author
Owner

@BHWarrior commented on GitHub (May 14, 2021):

@benyhirmansyah, it looks like everything is ok in your log

But when I try curl http://127.0.0.1:3000, I got this:

curl: (56) Recv failure: Connection reset by peer

Also, when I tried on browser, I got 502 Bad Gateway on nginx response.

It's because my ConfigServer Security & Firewall (csf) setting. Sorry... Once I disable the firewall, it's working. I'll check my config again so I can enable my firewall together with planka.

@BHWarrior commented on GitHub (May 14, 2021): > > @benyhirmansyah, it looks like everything is ok in your log > > But when I try `curl http://127.0.0.1:3000`, I got this: > > `curl: (56) Recv failure: Connection reset by peer` > > Also, when I tried on browser, I got 502 Bad Gateway on nginx response. It's because my ConfigServer Security & Firewall (csf) setting. Sorry... Once I disable the firewall, it's working. I'll check my config again so I can enable my firewall together with planka.
Author
Owner

@Jummit commented on GitHub (May 16, 2021):

@Jummit, do you use the default docker-compose config?

Yes. I don't know where to make it connect to localhost.

@Jummit commented on GitHub (May 16, 2021): > @Jummit, do you use the default docker-compose config? Yes. I don't know where to make it connect to localhost.
Author
Owner

@forrestab commented on GitHub (Jun 2, 2021):

@Jummit I had to specify a different ip address to postgres for my setup, I used the following uri:

postgresql://<user>:<password>@<host>/<db-name>

You can find more about the connection uris here under 33.1.1.2. Connection URIs. Hope this helps.

@forrestab commented on GitHub (Jun 2, 2021): @Jummit I had to specify a different ip address to postgres for my setup, I used the following uri: ``` postgresql://<user>:<password>@<host>/<db-name> ``` You can find more about the connection uris [here](https://www.postgresql.org/docs/12/libpq-connect.html) under _33.1.1.2. Connection URIs_. Hope this helps.
Author
Owner

@Jummit commented on GitHub (Jun 2, 2021):

@Jummit I had to specify a different ip address to postgres for my setup, I used the following uri:

postgresql://<user>:<password>@<host>/<db-name>

You can find more about the connection uris here under 33.1.1.2. Connection URIs. Hope this helps.

Sorry, but I don't understand docker or the planka codebase well enough to know where to change that url. Is it in docker_compose.yml or somewhere else?

@Jummit commented on GitHub (Jun 2, 2021): > @Jummit I had to specify a different ip address to postgres for my setup, I used the following uri: > > ``` > postgresql://<user>:<password>@<host>/<db-name> > ``` > > You can find more about the connection uris [here](https://www.postgresql.org/docs/12/libpq-connect.html) under _33.1.1.2. Connection URIs_. Hope this helps. Sorry, but I don't understand docker or the planka codebase well enough to know where to change that url. Is it in `docker_compose.yml` or somewhere else?
Author
Owner

@forrestab commented on GitHub (Jun 25, 2021):

@Jummit this would be the DATABASE_URL env variable in your docker-compose.yml file.

@forrestab commented on GitHub (Jun 25, 2021): @Jummit this would be the `DATABASE_URL` env variable in your docker-compose.yml file.
Author
Owner

@Jummit commented on GitHub (Jun 25, 2021):

EHOSTUNREACH probably means that the host cannot be found. Our own database runs on localhost and localhost is used for the connection. So I would probably change 172.16.0.2 to localhost

Setting DATABASE_URL to postgresql://localhost/planka doesn't work.

@Jummit this would be the DATABASE_URL env variable in your docker-compose.yml file.

I tried that and got an EHOSTUNREACH error with this url: DATABASE_URL=postgresql://jummit:Password@jummit/planka

curl http://127.0.0.1:3000
results in
curl: (56) Recv failure: Connection reset by peer

@Jummit commented on GitHub (Jun 25, 2021): > EHOSTUNREACH probably means that the host cannot be found. Our own database runs on localhost and localhost is used for the connection. So I would probably change 172.16.0.2 to localhost Setting DATABASE_URL to `postgresql://localhost/planka` doesn't work. > @Jummit this would be the `DATABASE_URL` env variable in your docker-compose.yml file. I tried that and got an EHOSTUNREACH error with this url: `DATABASE_URL=postgresql://jummit:Password@jummit/planka` `curl http://127.0.0.1:3000` results in `curl: (56) Recv failure: Connection reset by peer`
Author
Owner

@forrestab commented on GitHub (Jul 12, 2021):

@Jummit going on the statement above where you said you were using the docker-compose from this repo, I would assume the connection string to the postgres db would contain the service name, i.e. postgres.

DATABASE_URL=postgresql://<username>:<password>@postgres/planka

When I said that I had to specify a different ip address to connect to my db instance, it was because my db instance wasnt on the same docker network as my planka instance. But if you are running docker-compose up then docker-compose creates a network for that script and all services configured in it, so you should be good to use the service name.

@forrestab commented on GitHub (Jul 12, 2021): @Jummit going on the statement above where you said you were using the docker-compose from this repo, I would assume the connection string to the postgres db would contain the service name, i.e. postgres. ``` DATABASE_URL=postgresql://<username>:<password>@postgres/planka ``` When I said that I had to specify a different ip address to connect to my db instance, it was because my db instance wasnt on the same docker network as my planka instance. But if you are running `docker-compose up` then docker-compose creates a network for that script and all services configured in it, so you should be good to use the service name.
Author
Owner

@Jummit commented on GitHub (Dec 1, 2021):

I'll close this issue since it was resolved after doing a clean install.

@Jummit commented on GitHub (Dec 1, 2021): I'll close this issue since it was resolved after doing a clean install.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/planka#102