Invalid connection string for external Postgres DB? #309

Closed
opened 2026-04-05 16:17:21 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @electricmessiah on 8/10/2025

I have an existing container for Postgresql 15. It works perfectly with several other containers referencing it. However, I cannot get OpenArchiver (OA) to connect to it. I've tried several permutations of the connection URL to no avail. Hoping someone can point out my errors.

I am using Portainer and using the OA provided compose to create the stack. I've commented out the Postgres section, added my external network, and have loaded the .env file and populated it with my credentials.

  • String: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresdb:5432/${POSTGRES_DB}"
  • External network: dockernet
  • External PG container: postgresdb

CONSOLE ERROR

[dotenv@17.2.0] injecting env (0) from .env (tip: ⚙️  load multiple .env files with { path: ['.env.local', '.env'] })
Migration failed! TypeError: Invalid URL
    at new URL (node:internal/url:825:25)
    at parseUrl (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:544:18)
    at parseOptions (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:436:30)
    at Postgres (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:50:19)
    at runMigrate (/app/packages/backend/dist/database/migrate.js:15:47)
    at Object.<anonymous> (/app/packages/backend/dist/database/migrate.js:22:1)
    at Module._compile (node:internal/modules/cjs/loader:1688:14)
    at Object..js (node:internal/modules/cjs/loader:1820:10)
    at Module.load (node:internal/modules/cjs/loader:1423:32)
    at Function._load (node:internal/modules/cjs/loader:1246:12) {
  code: 'ERR_INVALID_URL',
  input: 'postgresql://postgres:post!@#@postgresdb:5432/open_archive'
}
/app/packages/backend:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @open-archiver/backend@0.1.0 db:migrate: `node dist/database/migrate.js`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

COMPOSE

version: '3.8'

services:
    open-archiver:
        image: logiclabshq/open-archiver:latest
        container_name: open-archiver
        restart: unless-stopped
        ports:
            - '4007:4000' # Backend
            - '3007:3000' # Frontend
        #env_file:
            #- .env
        env_file:
            - stack.env            
        external_links: 
          - postgresdb:postgres               
        volumes:
            - archiver-data:/var/data/open-archiver
        depends_on:
            #- postgres
            - valkey
            - meilisearch
        networks:
            - dockernet

#    postgres:
#        image: postgres:17-alpine
#        container_name: postgres
#        restart: unless-stopped
#        environment:
#            POSTGRES_DB: ${POSTGRES_DB:-open_archive}
#            POSTGRES_USER: ${POSTGRES_USER:-admin}
#            POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
#        volumes:
#            - pgdata:/var/lib/postgresql/data
#        ports:
#            - '5435:5432'
#        networks:
#            - dockernet

    valkey:
        image: valkey/valkey:8-alpine
        container_name: valkey
        restart: unless-stopped
        command: valkey-server --requirepass ${REDIS_PASSWORD}
        ports:
            - '6379:6379'
        volumes:
            - valkeydata:/data
        networks:
            - dockernet

    meilisearch:
        image: getmeili/meilisearch:v1.15
        container_name: meilisearch
        restart: unless-stopped
        environment:
            MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-aSampleMasterKey}
        ports:
            - '7700:7700'
        volumes:
            - meilidata:/meili_data
        networks:
            - dockernet

volumes:
    #pgdata:
        #driver: local
    valkeydata:
        driver: local
    meilidata:
        driver: local
    archiver-data:
        driver: local

###########
########### EXTERNAL
###########  
networks:
  dockernet:
    external: true

.ENV

NODE_ENV=development
PORT_BACKEND=4007
PORT_FRONTEND=3007
POSTGRES_DB=open_archive
POSTGRES_USER=postgres
POSTGRES_PASSWORD=post!@#
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresdb:5432/${POSTGRES_DB}"
MEILI_MASTER_KEY=aSampleMasterKey
MEILI_HOST=http://meilisearch:7700
REDIS_HOST=valkey
REDIS_PORT=6379
REDIS_PASSWORD=defaultredispassword
REDIS_TLS_ENABLED=false
STORAGE_TYPE=local
STORAGE_LOCAL_ROOT_PATH=/var/data/open-archiver
STORAGE_S3_ENDPOINT=
STORAGE_S3_BUCKET=
STORAGE_S3_ACCESS_KEY_ID=
STORAGE_S3_SECRET_ACCESS_KEY=
STORAGE_S3_REGION=
STORAGE_S3_FORCE_PATH_STYLE=false
JWT_SECRET=a-very-secret-key-that-you-should-change
JWT_EXPIRES_IN="7d"
ADMIN_EMAIL=admin@local.com
ADMIN_PASSWORD=a_strong_password_that_you_should_change
SUPER_API_KEY=
ENCRYPTION_KEY=3a84114a4cbafd6de94eb9576d9abdc26689b1b3fec10296cb95f5a18d805750
*Originally created by @electricmessiah on 8/10/2025* I have an existing container for Postgresql 15. It works perfectly with several other containers referencing it. However, I cannot get OpenArchiver (OA) to connect to it. I've tried several permutations of the connection URL to no avail. Hoping someone can point out my errors. I am using Portainer and using the OA provided compose to create the stack. I've commented out the Postgres section, added my external network, and have loaded the .env file and populated it with my credentials. - String: "postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresdb:5432/${POSTGRES_DB}" - External network: dockernet - External PG container: postgresdb **CONSOLE ERROR** ``` [dotenv@17.2.0] injecting env (0) from .env (tip: ⚙️ load multiple .env files with { path: ['.env.local', '.env'] }) Migration failed! TypeError: Invalid URL at new URL (node:internal/url:825:25) at parseUrl (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:544:18) at parseOptions (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:436:30) at Postgres (/app/node_modules/.pnpm/postgres@3.4.7/node_modules/postgres/cjs/src/index.js:50:19) at runMigrate (/app/packages/backend/dist/database/migrate.js:15:47) at Object.<anonymous> (/app/packages/backend/dist/database/migrate.js:22:1) at Module._compile (node:internal/modules/cjs/loader:1688:14) at Object..js (node:internal/modules/cjs/loader:1820:10) at Module.load (node:internal/modules/cjs/loader:1423:32) at Function._load (node:internal/modules/cjs/loader:1246:12) { code: 'ERR_INVALID_URL', input: 'postgresql://postgres:post!@#@postgresdb:5432/open_archive' } /app/packages/backend:  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @open-archiver/backend@0.1.0 db:migrate: `node dist/database/migrate.js` Exit status 1  ELIFECYCLE  Command failed with exit code 1. ``` **COMPOSE** ``` version: '3.8' services: open-archiver: image: logiclabshq/open-archiver:latest container_name: open-archiver restart: unless-stopped ports: - '4007:4000' # Backend - '3007:3000' # Frontend #env_file: #- .env env_file: - stack.env external_links: - postgresdb:postgres volumes: - archiver-data:/var/data/open-archiver depends_on: #- postgres - valkey - meilisearch networks: - dockernet # postgres: # image: postgres:17-alpine # container_name: postgres # restart: unless-stopped # environment: # POSTGRES_DB: ${POSTGRES_DB:-open_archive} # POSTGRES_USER: ${POSTGRES_USER:-admin} # POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} # volumes: # - pgdata:/var/lib/postgresql/data # ports: # - '5435:5432' # networks: # - dockernet valkey: image: valkey/valkey:8-alpine container_name: valkey restart: unless-stopped command: valkey-server --requirepass ${REDIS_PASSWORD} ports: - '6379:6379' volumes: - valkeydata:/data networks: - dockernet meilisearch: image: getmeili/meilisearch:v1.15 container_name: meilisearch restart: unless-stopped environment: MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-aSampleMasterKey} ports: - '7700:7700' volumes: - meilidata:/meili_data networks: - dockernet volumes: #pgdata: #driver: local valkeydata: driver: local meilidata: driver: local archiver-data: driver: local ########### ########### EXTERNAL ########### networks: dockernet: external: true ``` **.ENV** ``` NODE_ENV=development PORT_BACKEND=4007 PORT_FRONTEND=3007 POSTGRES_DB=open_archive POSTGRES_USER=postgres POSTGRES_PASSWORD=post!@# DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresdb:5432/${POSTGRES_DB}" MEILI_MASTER_KEY=aSampleMasterKey MEILI_HOST=http://meilisearch:7700 REDIS_HOST=valkey REDIS_PORT=6379 REDIS_PASSWORD=defaultredispassword REDIS_TLS_ENABLED=false STORAGE_TYPE=local STORAGE_LOCAL_ROOT_PATH=/var/data/open-archiver STORAGE_S3_ENDPOINT= STORAGE_S3_BUCKET= STORAGE_S3_ACCESS_KEY_ID= STORAGE_S3_SECRET_ACCESS_KEY= STORAGE_S3_REGION= STORAGE_S3_FORCE_PATH_STYLE=false JWT_SECRET=a-very-secret-key-that-you-should-change JWT_EXPIRES_IN="7d" ADMIN_EMAIL=admin@local.com ADMIN_PASSWORD=a_strong_password_that_you_should_change SUPER_API_KEY= ENCRYPTION_KEY=3a84114a4cbafd6de94eb9576d9abdc26689b1b3fec10296cb95f5a18d805750 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OpenArchiver#309