[Feature]: Using External Postgres/Redis #295

Closed
opened 2026-02-04 19:25:03 +03:00 by OVERLORD · 10 comments
Owner

Originally created by @ajay-actuary on GitHub (Sep 11, 2022).

Feature detail

I have a common postgres/redis server running for nextcloud, home assistant, lychee etc (not installed as a docker but as a system repo app). Is it possible for immich to use an external postgres/redis server rather than as a part of it's docker container? I tried removing the depends on in the docker & modifying the postgres/redis host but I'm not successful. Any help will be appreciated. Thanks!

Platform

Server

Originally created by @ajay-actuary on GitHub (Sep 11, 2022). ### Feature detail I have a common postgres/redis server running for nextcloud, home assistant, lychee etc (not installed as a docker but as a system repo app). Is it possible for immich to use an external postgres/redis server rather than as a part of it's docker container? I tried removing the depends on in the docker & modifying the postgres/redis host but I'm not successful. Any help will be appreciated. Thanks! ### Platform Server
Author
Owner

@bo0tzz commented on GitHub (Sep 11, 2022):

You need to edit the .env file to use the external services.

@bo0tzz commented on GitHub (Sep 11, 2022): You need to edit the .env file to use the external services.
Author
Owner

@ajay-actuary commented on GitHub (Sep 11, 2022):

Below is my docker-compose. (I also edited the .env file & removed redis/postgres docker) I keep getting

Error code 500
Request failed with status code 502

Verbose
Request failed with status code 502,AxiosError,ERR_BAD_RESPONSE,[object Object],[object XMLHttpRequest],[object Object]



version: "3.8"

services:
  immich-server:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    volumes:
      - /absolutepath/:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - POSTGRES_DB=immich
      - POSTGRES_USER=immich
      - POSTGRES_PASSWORD=mypass
      - POSTGRES_HOST=postgres_host
      - REDIS_HOST=redis_host
      - REDIS_HOST_PORT=redis_port
      - REDIS_HOST_PASSWORD=redis_pass
    restart: always

  immich-microservices:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    volumes:
      - /absolutepath/:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - POSTGRES_DB=immich
      - POSTGRES_USER=immich
      - POSTGRES_PASSWORD=mypass
      - POSTGRES_HOST=postgres_host
      - REDIS_HOST=redis_host
      - REDIS_HOST_PORT=redis_port
      - REDIS_HOST_PASSWORD=redis_pass
    restart: always

  immich-machine-learning:
    image: altran1502/immich-machine-learning:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    volumes:
      - /absolutepath/:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
      - POSTGRES_DB=immich
      - POSTGRES_USER=immich
      - POSTGRES_PASSWORD=mypass
      - POSTGRES_HOST=postgres_host
    restart: always

  immich-web:
    image: altran1502/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    env_file:
      - .env
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: altran1502/immich-proxy:release
    ports:
      - 2283:80
    logging:
      driver: none
    depends_on:
      - immich-server
    restart: always

volumes:
  pgdata:

@ajay-actuary commented on GitHub (Sep 11, 2022): Below is my docker-compose. (I also edited the .env file & removed redis/postgres docker) I keep getting Error code 500 Request failed with status code 502 Verbose Request failed with status code 502,AxiosError,ERR_BAD_RESPONSE,[object Object],[object XMLHttpRequest],[object Object] ----------------------------------------------------- ``` version: "3.8" services: immich-server: image: altran1502/immich-server:release entrypoint: ["/bin/sh", "./start-server.sh"] volumes: - /absolutepath/:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production - POSTGRES_DB=immich - POSTGRES_USER=immich - POSTGRES_PASSWORD=mypass - POSTGRES_HOST=postgres_host - REDIS_HOST=redis_host - REDIS_HOST_PORT=redis_port - REDIS_HOST_PASSWORD=redis_pass restart: always immich-microservices: image: altran1502/immich-server:release entrypoint: ["/bin/sh", "./start-microservices.sh"] volumes: - /absolutepath/:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production - POSTGRES_DB=immich - POSTGRES_USER=immich - POSTGRES_PASSWORD=mypass - POSTGRES_HOST=postgres_host - REDIS_HOST=redis_host - REDIS_HOST_PORT=redis_port - REDIS_HOST_PASSWORD=redis_pass restart: always immich-machine-learning: image: altran1502/immich-machine-learning:release entrypoint: ["/bin/sh", "./entrypoint.sh"] volumes: - /absolutepath/:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production - POSTGRES_DB=immich - POSTGRES_USER=immich - POSTGRES_PASSWORD=mypass - POSTGRES_HOST=postgres_host restart: always immich-web: image: altran1502/immich-web:release entrypoint: ["/bin/sh", "./entrypoint.sh"] env_file: - .env restart: always immich-proxy: container_name: immich_proxy image: altran1502/immich-proxy:release ports: - 2283:80 logging: driver: none depends_on: - immich-server restart: always volumes: pgdata: ```
Author
Owner

@bo0tzz commented on GitHub (Sep 11, 2022):

Can you post your redacted .env file as well?
Looking at the env vars you have set in the docker-compose.yml, - POSTGRES_HOST=postgres_host does not seem correct. Is that the actual address of your postgres instance?

@bo0tzz commented on GitHub (Sep 11, 2022): Can you post your redacted .env file as well? Looking at the env vars you have set in the docker-compose.yml, `- POSTGRES_HOST=postgres_host` does not seem correct. Is that the actual address of your postgres instance?
Author
Owner

@ajay-actuary commented on GitHub (Sep 11, 2022):

Can you post your redacted .env file as well? Looking at the env vars you have set in the docker-compose.yml, - POSTGRES_HOST=postgres_host does not seem correct. Is that the actual address of your postgres instance?

Thanks for your help. Below is my env file. Yes, that's the postgres host running at 192.168.x.x


###################################################################################
# Database
###################################################################################

DB_HOSTNAME=192.168.x.x
DB_USERNAME=immich
DB_PASSWORD=postgres_pass
DB_DATABASE_NAME=immich

# Optional Database settings:
# DB_PORT=5432




###################################################################################
# Redis
###################################################################################

REDIS_HOSTNAME=192.168.x.x

# Optional Redis settings:
# REDIS_PORT=6379
# REDIS_DBINDEX=0
REDIS_PASSWORD=redis_pass
# REDIS_SOCKET=





###################################################################################
# Upload File Config
###################################################################################

UPLOAD_LOCATION=/home/xx/Apps/Immich/config




###################################################################################
# JWT SECRET
###################################################################################

JWT_SECRET=mysecret




###################################################################################
# MAPBOX
####################################################################################

# ENABLE_MAPBOX is either true of false -> if true, you have to provide MAPBOX_KEY
ENABLE_MAPBOX=false
MAPBOX_KEY=


####################################################################################
# WEB - Optional
####################################################################################

# Custom message on the login page, should be written in HTML form.
# For example PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>"

PUBLIC_LOGIN_PAGE_MESSAGE="Welcome to Home Server Immich"
@ajay-actuary commented on GitHub (Sep 11, 2022): > Can you post your redacted .env file as well? Looking at the env vars you have set in the docker-compose.yml, `- POSTGRES_HOST=postgres_host` does not seem correct. Is that the actual address of your postgres instance? Thanks for your help. Below is my env file. Yes, that's the postgres host running at 192.168.x.x ``` ################################################################################### # Database ################################################################################### DB_HOSTNAME=192.168.x.x DB_USERNAME=immich DB_PASSWORD=postgres_pass DB_DATABASE_NAME=immich # Optional Database settings: # DB_PORT=5432 ################################################################################### # Redis ################################################################################### REDIS_HOSTNAME=192.168.x.x # Optional Redis settings: # REDIS_PORT=6379 # REDIS_DBINDEX=0 REDIS_PASSWORD=redis_pass # REDIS_SOCKET= ################################################################################### # Upload File Config ################################################################################### UPLOAD_LOCATION=/home/xx/Apps/Immich/config ################################################################################### # JWT SECRET ################################################################################### JWT_SECRET=mysecret ################################################################################### # MAPBOX #################################################################################### # ENABLE_MAPBOX is either true of false -> if true, you have to provide MAPBOX_KEY ENABLE_MAPBOX=false MAPBOX_KEY= #################################################################################### # WEB - Optional #################################################################################### # Custom message on the login page, should be written in HTML form. # For example PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>" PUBLIC_LOGIN_PAGE_MESSAGE="Welcome to Home Server Immich" ```
Author
Owner

@bo0tzz commented on GitHub (Sep 11, 2022):

The environment variables you're setting in the environment: section of the docker-compose are overriding the ones from the .env file. Please remove them, then it should work.

@bo0tzz commented on GitHub (Sep 11, 2022): The environment variables you're setting in the `environment:` section of the docker-compose are overriding the ones from the .env file. Please remove them, then it should work.
Author
Owner

@ajay-actuary commented on GitHub (Sep 11, 2022):

Thanks. I get the same error:

immich-immich-server-1            | [Nest] 7  - 09/11/2022, 12:01:16 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
immich-immich-server-1            | QueryFailedError: function uuid_generate_v4() does not exist
immich-immich-server-1            |     at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
immich-immich-server-1            |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
immich-immich-server-1            |     at async CreateUserTable1645130759468.up (/usr/src/app/dist/apps/immich/libs/database/src/migrations/1645130759468-CreateUserTable.js:6:9)
immich-immich-server-1            |     at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:178:17)
immich-immich-server-1            |     at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:248:35)
immich-immich-server-1            |     at async DataSource.initialize (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:137:17)
immich-immich-server-1            | Migration "CreateUserTable1645130759468" failed, error: function uuid_generate_v4() does not exist

version: "3.8"

services:
  immich-server:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-server.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    restart: always

  immich-microservices:
    image: altran1502/immich-server:release
    entrypoint: ["/bin/sh", "./start-microservices.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    restart: always

  immich-machine-learning:
    image: altran1502/immich-machine-learning:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    restart: always

  immich-web:
    image: altran1502/immich-web:release
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    env_file:
      - .env
    restart: always


  immich-proxy:
    container_name: immich_proxy
    image: altran1502/immich-proxy:release
    ports:
      - 2283:80
    logging:
      driver: none
    depends_on:
      - immich-server
    restart: always

@ajay-actuary commented on GitHub (Sep 11, 2022): Thanks. I get the same error: ``` immich-immich-server-1 | [Nest] 7 - 09/11/2022, 12:01:16 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... immich-immich-server-1 | QueryFailedError: function uuid_generate_v4() does not exist immich-immich-server-1 | at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) immich-immich-server-1 | at processTicksAndRejections (node:internal/process/task_queues:96:5) immich-immich-server-1 | at async CreateUserTable1645130759468.up (/usr/src/app/dist/apps/immich/libs/database/src/migrations/1645130759468-CreateUserTable.js:6:9) immich-immich-server-1 | at async MigrationExecutor.executePendingMigrations (/usr/src/app/node_modules/typeorm/migration/MigrationExecutor.js:178:17) immich-immich-server-1 | at async DataSource.runMigrations (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:248:35) immich-immich-server-1 | at async DataSource.initialize (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:137:17) immich-immich-server-1 | Migration "CreateUserTable1645130759468" failed, error: function uuid_generate_v4() does not exist ``` ``` version: "3.8" services: immich-server: image: altran1502/immich-server:release entrypoint: ["/bin/sh", "./start-server.sh"] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production restart: always immich-microservices: image: altran1502/immich-server:release entrypoint: ["/bin/sh", "./start-microservices.sh"] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production restart: always immich-machine-learning: image: altran1502/immich-machine-learning:release entrypoint: ["/bin/sh", "./entrypoint.sh"] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production restart: always immich-web: image: altran1502/immich-web:release entrypoint: ["/bin/sh", "./entrypoint.sh"] env_file: - .env restart: always immich-proxy: container_name: immich_proxy image: altran1502/immich-proxy:release ports: - 2283:80 logging: driver: none depends_on: - immich-server restart: always ```
Author
Owner

@bo0tzz commented on GitHub (Sep 11, 2022):

Make sure you're using postgres 14 and that the uuid-ossp extension is installed. (CREATE EXTENSION IF NOT EXISTS "uuid-ossp";)

@bo0tzz commented on GitHub (Sep 11, 2022): Make sure you're using postgres 14 and that the `uuid-ossp` extension is installed. (`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`)
Author
Owner

@ajay-actuary commented on GitHub (Sep 11, 2022):

Yes, I'm running postgres 14.5 & have installed uuid-ossp. I keep getting the same error.


postgres (PostgreSQL) 14.5

postgres=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
NOTICE:  extension "uuid-ossp" already exists, skipping
CREATE EXTENSION

@ajay-actuary commented on GitHub (Sep 11, 2022): Yes, I'm running postgres 14.5 & have installed uuid-ossp. I keep getting the same error. ``` postgres (PostgreSQL) 14.5 postgres=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; NOTICE: extension "uuid-ossp" already exists, skipping CREATE EXTENSION ```
Author
Owner

@bo0tzz commented on GitHub (Sep 11, 2022):

Does it exist on the immich database?

@bo0tzz commented on GitHub (Sep 11, 2022): Does it exist on the `immich` database?
Author
Owner

@ajay-actuary commented on GitHub (Sep 11, 2022):

Does it exist on the immich database?

How absolutely stupid of me. This is the issue - I created the extension in postgres database! Thanks! Really appreciate your help!

@ajay-actuary commented on GitHub (Sep 11, 2022): > Does it exist on the `immich` database? How absolutely stupid of me. This is the issue - I created the extension in postgres database! Thanks! Really appreciate your help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#295