Skip to content

[bug] FATAL: password authentication failed after fresh auto-install on old data path #562

@nemesifier

Description

@nemesifier

Describe the bug

Stemming from https://github.com/orgs/openwisp/discussions/1213.

The auto-install.sh script generates a new .env file with randomized database credentials (DB_USER, DB_PASSWORD) on every new installation. If a user attempts to reinstall or recover a setup by re-running the script without purging existing Docker volumes, a credential mismatch occurs.

The PostgreSQL container retains the original credentials stored in its persistent data volume, while the OpenWISP application containers attempt to authenticate using the newly generated credentials in the .env file. This results in a permanent "FATAL: password authentication failed" error.

Steps To Reproduce

  1. Install docker-openwisp using the auto-install.sh script.
  2. Stop the containers using docker compose down (without the --volumes flag).
  3. Delete the .env file or the configuration directory.
  4. Run the auto-install.sh script again to generate a fresh configuration.
  5. Attempt to start the stack; the application will fail to connect to the database.

Expected behavior

The installation process should be idempotent or provide a warning when existing volumes are detected. If the .env file is missing but volumes are present, the script should ideally warn the user that generating new credentials will break database connectivity unless the volumes are also cleared.

Screenshots

N/A

System Information:

  • OS: Ubuntu 24.04 LTS
  • Docker version: Docker version 28.1.1

Suggested Mitigation

For users encountering this, the following command must be run to ensure the database is initialized with the current .env credentials (note that this deletes all existing data):

docker compose -f /opt/openwisp/docker-openwisp/docker-compose.yml down --volumes

Alternatively, the auto-install.sh script could be updated to check for existing openwisp_db_data volumes and prompt the user for confirmation before proceeding with new credential generation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    To do

    Status

    To do (ansible/docker)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions