Skip to content

Setup with Postgres Problem: WARN PostgreSQL connection error. Falling back to SQLite. #189

@haferm

Description

@haferm

Description
running a setup with postgres db instead of sqlite in one docker-compose setup.
This works fine with docker compose up and down as i also include healthcheck etc.
However if your reboot docker host, watchyourlan fails over to sqlite

Steps to Reproduce
Reboot docker host and/or restart containers with stop/start

Expected Behavior
Once postgres is configured, wyl should retry connection and only should use postgres as db.

Actual Behavior
Rebooting docker host or stopping/restarting containers during a backup pre/post cuasing wyl failing over to sqllite

Screenshots or Logs

just after starting compose stach with docker compose up

2025/05/23 09:01:15 INFO Log level=INFO
2025/05/23 09:01:15 INFO Using DB type=postgres
2025/05/23 09:01:15 INFO Config dir path=/data/WatchYourLAN
2025/05/23 09:01:15 INFO ===================================
2025/05/23 09:01:15 INFO Web GUI at http://0.0.0.0:8840
2025/05/23 09:01:15 INFO ===================================
2025/05/23 09:01:15 INFO Removing all History before date="2025-05-21 09:01:15"
2025/05/23 09:01:15 INFO Removed records from History n=0

after rebooting docker host

2025/05/23 10:13:27 INFO Log level=INFO
2025/05/23 10:13:27 INFO Using DB type=postgres
2025/05/23 10:13:27 ERROR dial tcp 127.0.0.1:5432: connect: connection refused
2025/05/23 10:13:27 WARN PostgreSQL connection error. Falling back to SQLite.
2025/05/23 10:13:27 INFO Using DB type=sqlite
2025/05/23 10:13:27 INFO Config dir path=/data/WatchYourLAN
2025/05/23 10:13:27 INFO ===================================
2025/05/23 10:13:27 INFO Web GUI at http://0.0.0.0:8840
2025/05/23 10:13:27 INFO ===================================
2025/05/23 10:13:27 INFO Removing all History before date="2025-05-21 10:13:27"
2025/05/23 10:13:27 INFO Removed records from History n=0

Environment:
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm

Server: Docker Engine - Community
Engine:
Version: 28.1.1

Docker Compose version v2.35.1

Additional Context
my compose file
(Private data such as IP addresses, passwords, and access tokens have been replaced with placeholders (e.g., xx.xx.xx.xx, , ) for security reasons.)

services:
  postgres:
    image: postgres:16
    container_name: watchyourlan_db
    restart: unless-stopped
    environment:
      POSTGRES_USER: wyluser
      POSTGRES_PASSWORD: <PASSWORD>
      POSTGRES_DB: wyl_db
    ports:
      - "5432:5432"
    volumes:
      - ./db_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U wyluser -d <PASSWORD>"]
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
  wyl:
    image: aceberg/watchyourlan
    container_name: watchyourlan
    network_mode: "host"
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
    - ./data:/data/WatchYourLAN
    environment:
      TZ: Europe/Berlin              # required: needs your TZ for correct time
    #  IFACES: "enp4s0 wlxf4ec3892dd51"  # required: 1 or more interface
      IFACES: "enp2s0"                   # required: 1 or more interface
      ARP_STRS_JOINED: "-gNx xx.xx.xx.xx/24 -Q xx -I enp2s0,-gNx xx.xx.xx.xx/24 -Q xx -I enp2s0,-gNx xx.xx.xx.xx/24 -Q xx -I enp2s0"
      HIST_IN_DB: "true"
      TRIM_HIST: "48"
      HOST: "0.0.0.0"                   # optional, default: 0.0.0.0
      PORT: "8840"                      # optional, default: 8840
      TIMEOUT: "120"                    # optional, time in seconds, default: 120
      THEME: "sand"                     # optional
      COLOR: "dark"                     # optional
      USE_DB: "postgres"
      PG_CONNECT: "postgres://wyluser:<PASSWORD>@127.0.0.1:5432/wyl_db?sslmode=disable"
volumes:
  db_data:
  data:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions