I
Immich5mo ago
molemanx

ECONNREFUSED - Unable To Connect To Database

Hi, I've been trying to set up immich for a few hours now but can't get past this error. I'm happy to post logs, I'm using the recommended docker compose setup however I have adapted the compose file for my own setup. Please see below for my compose file. This is a completely new install and I've already tried a couple fixes such as switching the postgres container, deleting all postgres files and restarting my entire stack multiple times. Any help is hugely appreciated, I'm at a complete loss with this and after reading multiple reddit and github posts I thought it was best to just post here. Thank you!
16 Replies
Immich
Immich5mo ago
:wave: Hey @molemanx, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :blue_square: verified I'm on the latest release(note that mobile app releases may take some time). 2. :blue_square: read applicable release notes. 3. :blue_square: reviewed the FAQs for known issues. 4. :blue_square: reviewed Github for known issues. 5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy). 6. :blue_square: uploaded the relevant information (see below). 7. :blue_square: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed.
Zeus
Zeus5mo ago
please post the postgres container logs, you might need to go into the postgres folder to find thme
molemanx
molemanxOP5mo ago
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are enabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
waiting for server to start....2024-12-23 19:29:18.900 UTC [63] LOG: redirecting log output to logging collector process
2024-12-23 19:29:18.900 UTC [63] HINT: Future log output will appear in directory "log".
done
server started
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are enabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
waiting for server to start....2024-12-23 19:29:18.900 UTC [63] LOG: redirecting log output to logging collector process
2024-12-23 19:29:18.900 UTC [63] HINT: Future log output will appear in directory "log".
done
server started
Above is from a fresh install, after that no signs of any errors Then it creates the database as expected:
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
waiting for server to shut down.... done
server stopped
PostgreSQL init process complete; ready for start up.
2024-12-23 19:29:34.034 UTC [1] LOG: redirecting log output to logging collector process
2024-12-23 19:29:34.034 UTC [1] HINT: Future log output will appear in directory "log".
CREATE DATABASE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
waiting for server to shut down.... done
server stopped
PostgreSQL init process complete; ready for start up.
2024-12-23 19:29:34.034 UTC [1] LOG: redirecting log output to logging collector process
2024-12-23 19:29:34.034 UTC [1] HINT: Future log output will appear in directory "log".
molemanx
molemanxOP5mo ago
This is the error I get on the main immich container
Zeus
Zeus5mo ago
um what is this: 192.168.2.5 please post your env wait how are your passing the database info into immich..?
molemanx
molemanxOP5mo ago
I modified it so I'm not using a .env file, since I already have a .env file and I didn't want to overload it with variables 192.168.2.5 should be socket proxy But I can remove that if it's not needed, I was just trying to make sure the containers could talk to eachother
Zeus
Zeus5mo ago
how are you telling immich what database to connect to?? Please review our docs: https://immich.app/docs/install/environment-variables/ You MUST pass the DB_ urls into immich somehow. how you do this is up to you
molemanx
molemanxOP5mo ago
Is that within the setup here somewhere? https://immich.app/docs/install/docker-compose That's what I've been looking at, is that still correct? I've added the URL, but I don't understand why? The documentation states that it makes all the dbpasswords, DBusername, DBname and DBport redundant. I've added the url to the environment variable of postgres, still no luck sadly I now get the below error:
[Nest] 7 - 12/23/2024, 7:57:28 PM LOG [NestFactory] Starting Nest application...
[Nest] 7 - 12/23/2024, 7:57:28 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
microservices worker exited with code 1
Killing api process
23/12/2024
Container stopped
[Nest] 7 - 12/23/2024, 7:57:28 PM LOG [NestFactory] Starting Nest application...
[Nest] 7 - 12/23/2024, 7:57:28 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
microservices worker exited with code 1
Killing api process
23/12/2024
Container stopped
bo0tzz
bo0tzz5mo ago
Please start with just the default setup, then once that's working you can adapt it to whatever custom stuff you wanna do
molemanx
molemanxOP5mo ago
Alright, I'll try again tomorrow I didn't think I was doing anything too crazy, I had just replaced all the variables so they didn't have to sit in my env file, but oh well. I'm hopefully okay to use my existing env file? The reason I ended up doing it this way was because I had an env file already but it looked like the compose file was unable to reference above wherever the file sat for some reason
bo0tzz
bo0tzz5mo ago
What do you mean have an env file already?
molemanx
molemanxOP5mo ago
I have a 'master' docker compose file that pulls in all my docker compose files from one place. This sits next to an env file that contains domains, hostnames, directories for important data etc. It's already got a fair bit in it, so I just didn't want to clutter it further I'm sure I can work it out tomorrow, all good Thanks for your time
bo0tzz
bo0tzz5mo ago
There's... not really a good reason to do that, I think. It just mixes everything unnecessarily when half the point of compose is it gives you nice separation
Zeus
Zeus5mo ago
You should look at this PR to understand exactly what you need to do to remove the env_file. you did it poorly. #14889
Immich
Immich5mo ago
[Pull Request] feat(deployment): no env_file (immich-app/immich#14889)

Did you find this page helpful?