[BUG] connect ECONNREFUSED on fresh install Ubuntu 22.10 #622

Closed
opened 2026-02-04 21:32:46 +03:00 by OVERLORD · 15 comments
Owner

Originally created by @bihius on GitHub (Jan 28, 2023).

Immich server can't connect with postgre and postgre can't log in with default pass.
Task List

  • [ x ] I have read thoroughly the README setup and installation instructions.
  • [ x ] I have included my docker-compose file.
  • [ x ] I have included my redacted .env file.
  • [ x ] I have included information on my machine, and environment.

To Reproduce
Steps to reproduce the behavior:

  1. Install fresh Ubuntu 22.10
  2. Install docker
  3. Install Immich by docker compose

Hardware tested: VM.Standard.E2.1.Micro, Lenovo Z510 laptop
OS tested: Ubuntu 22.10

Expected behavior
Working connection with postgre.

Screenshots
Screenshot from 2023-01-27 21-54-39

System

  • Server Version: release

Additional context
Little changed env file:

DB_HOSTNAME=immich_postgres
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
REDIS_HOSTNAME=immich_redis
UPLOAD_LOCATION=/zdjecia/
JWT_SECRET=YGW5InCfxJTr2ZHQifeNUAnZyjbgi+jZEv+PZJXm5cYkESpgHRnd5XpGhzMrnvy3sw+5z486LrliGfXIEN3XI74Dmw91q9qY467fPOhqZpSfnxZjJeppyb80mhcQtOYiuJDcQiVJGDHPiz/ccDfhIQ6BQs3kFG8mLa6xRGLr8Vc=
PUBLIC_LOGIN_PAGE_MESSAGE="something"
IMMICH_WEB_URL=http://immich-web:3000
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

any changes in docker compose file

Originally created by @bihius on GitHub (Jan 28, 2023). Immich server can't connect with postgre and postgre can't log in with default pass. **Task List** - [ x ] I have read thoroughly the README setup and installation instructions. - [ x ] I have included my `docker-compose` file. - [ x ] I have included my redacted `.env` file. - [ x ] I have included information on my machine, and environment. **To Reproduce** Steps to reproduce the behavior: 1. Install fresh Ubuntu 22.10 2. Install docker 3. Install Immich by docker compose Hardware tested: VM.Standard.E2.1.Micro, Lenovo Z510 laptop OS tested: Ubuntu 22.10 **Expected behavior** Working connection with postgre. **Screenshots** ![Screenshot from 2023-01-27 21-54-39](https://user-images.githubusercontent.com/119067436/215195249-d8f3900b-597c-4df7-a35a-a9e2d2bd5e16.png) **System** - Server Version: `release` **Additional context** Little changed env file: ``` DB_HOSTNAME=immich_postgres DB_USERNAME=postgres DB_PASSWORD=postgres DB_DATABASE_NAME=immich REDIS_HOSTNAME=immich_redis UPLOAD_LOCATION=/zdjecia/ JWT_SECRET=YGW5InCfxJTr2ZHQifeNUAnZyjbgi+jZEv+PZJXm5cYkESpgHRnd5XpGhzMrnvy3sw+5z486LrliGfXIEN3XI74Dmw91q9qY467fPOhqZpSfnxZjJeppyb80mhcQtOYiuJDcQiVJGDHPiz/ccDfhIQ6BQs3kFG8mLa6xRGLr8Vc= PUBLIC_LOGIN_PAGE_MESSAGE="something" IMMICH_WEB_URL=http://immich-web:3000 IMMICH_SERVER_URL=http://immich-server:3001 IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003 ``` any changes in docker compose file
Author
Owner

@alextran1502 commented on GitHub (Jan 28, 2023):

Please use tag release as shown in the docker-compose file.

@alextran1502 commented on GitHub (Jan 28, 2023): Please use tag `release` as shown in the docker-compose file.
Author
Owner

@bihius commented on GitHub (Jan 28, 2023):

I used release tag, just write bad in this issue

@bihius commented on GitHub (Jan 28, 2023): > I used release tag, just write bad in this issue
Author
Owner

@jrasm91 commented on GitHub (Jan 28, 2023):

I'd try shutting the stack down, removing the postgres volume and then start everything up again. And/or show the logs for the immich_server container.

@jrasm91 commented on GitHub (Jan 28, 2023): I'd try shutting the stack down, removing the postgres volume and then start everything up again. And/or show the logs for the immich_server container.
Author
Owner

@bihius commented on GitHub (Jan 28, 2023):

I'd try shutting the stack down, removing the postgres volume and then start everything up again. And/or show the logs for the immich_server container.

In docker immich_server log, there is only:
[Nest] 1 - 01/27/2023, 9:41:48 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)... error: password authentication failed for user "postgres"

And in immich_postgre log there is info about that default 'postgres' user doesn't exist
(2023-01-27 21:42:54.970 UTC [91] DETAIL: Role "postgres" does not exist. Connection matched pg_hba.conf line 100: "host all all all scram-sha-256")

@bihius commented on GitHub (Jan 28, 2023): > I'd try shutting the stack down, removing the postgres volume and then start everything up again. And/or show the logs for the immich_server container. In docker immich_server log, there is only: `[Nest] 1 - 01/27/2023, 9:41:48 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)... error: password authentication failed for user "postgres" ` And in immich_postgre log there is info about that default 'postgres' user doesn't exist ` (2023-01-27 21:42:54.970 UTC [91] DETAIL: Role "postgres" does not exist. Connection matched pg_hba.conf line 100: "host all all all scram-sha-256") `
Author
Owner

@jrasm91 commented on GitHub (Jan 28, 2023):

That error should go away if you re-create the postgres data volume.

@jrasm91 commented on GitHub (Jan 28, 2023): That error should go away if you re-create the postgres data volume.
Author
Owner

@bihius commented on GitHub (Jan 28, 2023):

tried many times

@bihius commented on GitHub (Jan 28, 2023): tried many times
Author
Owner

@jrasm91 commented on GitHub (Jan 28, 2023):

tried many times

How did you remove the volume? Also, can you share the compose file? You either didn't attach it, or github auto-removed it. Maybe just add the postgres and immich-server sections as those seem to be problematic.

@jrasm91 commented on GitHub (Jan 28, 2023): > tried many times How did you remove the volume? Also, can you share the compose file? You either didn't attach it, or github auto-removed it. Maybe just add the postgres and immich-server sections as those seem to be problematic.
Author
Owner

@bihius commented on GitHub (Jan 28, 2023):

Everytime I just used docker compose with --force-recreate option. Compose file is untouched.

@bihius commented on GitHub (Jan 28, 2023): > Everytime I just used docker compose with --force-recreate option. Compose file is untouched.
Author
Owner

@jrasm91 commented on GitHub (Jan 28, 2023):

--force-recreate will re-create the containers, you need to delete the postgres volume. Do docker-compose down -v Or, if you have it mapped to an actual /data folder somewhere, you need to delete that.

@jrasm91 commented on GitHub (Jan 28, 2023): `--force-recreate` will re-create the containers, you need to delete the postgres _volume_. Do `docker-compose down -v` Or, if you have it mapped to an actual /data folder somewhere, you need to delete that.
Author
Owner

@bihius commented on GitHub (Jan 28, 2023):

--force-recreate will re-create the containers, you need to delete the postgres volume. Do docker-compose down -v Or, if you have it mapped to an actual /data folder somewhere, you need to delete that.

Oh, you are right. I forgot that --force-recreate option doesn't remove the volume. Thanks for help
Solution: If whatever goes wrong on first installation, you must remove postgres volume. Reinstallation instruction:
docker volume ls
docker volume rm "postgres_volume_name"
docker-compose up -d --force-recreate

@bihius commented on GitHub (Jan 28, 2023): > `--force-recreate` will re-create the containers, you need to delete the postgres _volume_. Do `docker-compose down -v` Or, if you have it mapped to an actual /data folder somewhere, you need to delete that. Oh, you are right. I forgot that `--force-recreate` option doesn't remove the volume. Thanks for help Solution: If whatever goes wrong on first installation, you must remove postgres volume. Reinstallation instruction: `docker volume ls ` `docker volume rm "postgres_volume_name"` `docker-compose up -d --force-recreate`
Author
Owner

@sbkg0002 commented on GitHub (Jan 28, 2023):

With these instructions, I still have this error:

[Nest] 1  - 01/28/2023, 10:13:56 AM     LOG [InstanceLoader] BackgroundTaskModule dependencies initialized +1ms
[Nest] 1  - 01/28/2023, 10:13:56 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

What I did:

docker compose stop
docker compose rm
docker volume rm docker_pgdata
docker-compose up -d --force-recreate

Anyone know what am I missing here? This is since the last update; before that everything was fine.

Edit: database logs:

PostgreSQL init process complete; ready for start up.

2023-01-28 10:18:55.821 UTC [1] LOG:  starting PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-01-28 10:18:55.821 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-01-28 10:18:55.821 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-01-28 10:18:55.834 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-01-28 10:18:55.842 UTC [63] LOG:  database system was shut down at 2023-01-28 10:18:55 UTC
2023-01-28 10:18:55.851 UTC [1] LOG:  database system is ready to accept connections
@sbkg0002 commented on GitHub (Jan 28, 2023): With these instructions, I still have this error: ``` [Nest] 1 - 01/28/2023, 10:13:56 AM LOG [InstanceLoader] BackgroundTaskModule dependencies initialized +1ms [Nest] 1 - 01/28/2023, 10:13:56 AM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) ``` What I did: ``` docker compose stop docker compose rm docker volume rm docker_pgdata docker-compose up -d --force-recreate ``` Anyone know what am I missing here? This is since the last update; before that everything was fine. Edit: database logs: ``` PostgreSQL init process complete; ready for start up. 2023-01-28 10:18:55.821 UTC [1] LOG: starting PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit 2023-01-28 10:18:55.821 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2023-01-28 10:18:55.821 UTC [1] LOG: listening on IPv6 address "::", port 5432 2023-01-28 10:18:55.834 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2023-01-28 10:18:55.842 UTC [63] LOG: database system was shut down at 2023-01-28 10:18:55 UTC 2023-01-28 10:18:55.851 UTC [1] LOG: database system is ready to accept connections ```
Author
Owner

@alextran1502 commented on GitHub (Jan 28, 2023):

With these instructions, I still have this error:


[Nest] 1  - 01/28/2023, 10:13:56 AM     LOG [InstanceLoader] BackgroundTaskModule dependencies initialized +1ms

[Nest] 1  - 01/28/2023, 10:13:56 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...

Error: connect ECONNREFUSED 127.0.0.1:5432

    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

What I did:


docker compose stop

docker compose rm

docker volume rm docker_pgdata

docker-compose up -d --force-recreate

Anyone know what am I missing here? This is since the last update; before that everything was fine.

Edit: database logs:


PostgreSQL init process complete; ready for start up.



2023-01-28 10:18:55.821 UTC [1] LOG:  starting PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

2023-01-28 10:18:55.821 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

2023-01-28 10:18:55.821 UTC [1] LOG:  listening on IPv6 address "::", port 5432

2023-01-28 10:18:55.834 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

2023-01-28 10:18:55.842 UTC [63] LOG:  database system was shut down at 2023-01-28 10:18:55 UTC

2023-01-28 10:18:55.851 UTC [1] LOG:  database system is ready to accept connections

@sbkg0002 You are probably using the older .env file that doesn't have the value db_hostname. Please copy the default value from the .example.env file to your environment and it should fix it

@alextran1502 commented on GitHub (Jan 28, 2023): > With these instructions, I still have this error: > > ``` > > [Nest] 1 - 01/28/2023, 10:13:56 AM LOG [InstanceLoader] BackgroundTaskModule dependencies initialized +1ms > > [Nest] 1 - 01/28/2023, 10:13:56 AM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... > > Error: connect ECONNREFUSED 127.0.0.1:5432 > > at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) > > ``` > > What I did: > > ``` > > docker compose stop > > docker compose rm > > docker volume rm docker_pgdata > > docker-compose up -d --force-recreate > > ``` > > Anyone know what am I missing here? This is since the last update; before that everything was fine. > > > > Edit: database logs: > > ``` > > PostgreSQL init process complete; ready for start up. > > > > 2023-01-28 10:18:55.821 UTC [1] LOG: starting PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit > > 2023-01-28 10:18:55.821 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 > > 2023-01-28 10:18:55.821 UTC [1] LOG: listening on IPv6 address "::", port 5432 > > 2023-01-28 10:18:55.834 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" > > 2023-01-28 10:18:55.842 UTC [63] LOG: database system was shut down at 2023-01-28 10:18:55 UTC > > 2023-01-28 10:18:55.851 UTC [1] LOG: database system is ready to accept connections > > ``` @sbkg0002 You are probably using the older .env file that doesn't have the value `db_hostname`. Please copy the default value from the .example.env file to your environment and it should fix it
Author
Owner

@sbkg0002 commented on GitHub (Jan 28, 2023):

Thanks @alextran1502. Will try asap. I noticed the 127/32 but would expect the container name there.

@sbkg0002 commented on GitHub (Jan 28, 2023): Thanks @alextran1502. Will try asap. I noticed the 127/32 but would expect the container name there.
Author
Owner

@sbkg0002 commented on GitHub (Jan 29, 2023):

Got it up and running, but now all my config and pictures are gone.
Is there any to reindex the pictures?

@sbkg0002 commented on GitHub (Jan 29, 2023): Got it up and running, but now all my config and pictures are gone. Is there any to reindex the pictures?
Author
Owner

@jrasm91 commented on GitHub (Jan 29, 2023):

You deleted the postgres data volume, so you essentially deleted your database. Your pictures will have to be re-imported unless you have a database backup.

@jrasm91 commented on GitHub (Jan 29, 2023): You deleted the postgres data volume, so you essentially deleted your database. Your pictures will have to be re-imported unless you have a database backup.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#622