taiga-docker icon indicating copy to clipboard operation
taiga-docker copied to clipboard

[BUG] password authentication failed for user "taiga"

Open jpaugh opened this issue 9 months ago • 3 comments

Edit: To save you some time, I eventually figured out my issue (see my comments in the thread). I'm leaving this open because it's an opportunity to improve the docs if you're so inclined. Thanks!

Summary When I try to create a self-hosted Taiga instance with custom passwords and secrets, I get an error when running ./taiga-manage.sh createsuperuser.

django.db.utils.OperationalError: connection to server at "taiga-db" (172.19.0.6), port 5432 failed: FATAL: password authentication failed for user "taiga"

Full command output at the bottom.

How can we reproduce the behavior

First, with default .env settings

./launch-all.sh
./taiga-manage.sh createsuperuser

Then, after editing the .env to that shown below

docker rm -f $(docker ps -aq)
docker rmi $(docker images -q)
./launch-all.sh
./taiga-manage.sh createsuperuser

My .env is shown below, as well as the full output of running ./taiga-manage.sh createsuperuser

Workarounds

$ docker rm -f $(docker ps -aq)
$ docker volume rm $(docker volume ls)
$ docker rmi $(docker images -q)

Originally, I forgot to remove the volumes.

Screenshots

Taiga environment Self-hosted, following these instructions

Desktop (please complete the following information):

  • OS: Linux
  • Browser:
  • Version: git stable branch (dde1dbe)
  • Docker version 27.3.1, build v27.3.1

Additional context

Env File

Here's my .env file. Of course, I'll change these, now!

# Taiga's URLs - Variables to define where Taiga should be served
TAIGA_SCHEME=http  # serve Taiga using "http" or "https" (secured) connection
TAIGA_DOMAIN=localhost:9000  # Taiga's base URL
SUBPATH="" # it'll be appended to the TAIGA_DOMAIN (use either "" or a "/subpath")
WEBSOCKETS_SCHEME=ws  # events connection protocol (use either "ws" or "wss")

# Taiga's Secret Key - Variable to provide cryptographic signing
SECRET_KEY="Rt!RXD?B6bf!3c@y!Ke?RAC&p#o6XYDnt4L!&ze"  # Please, change it to an unpredictable value!!

# Taiga's Database settings - Variables to create the Taiga database and connect to it
POSTGRES_USER=taiga  # user to connect to PostgreSQL
POSTGRES_PASSWORD="YiNBtnoBcnh!8YzKfxr47"  # database user's password

# Taiga's SMTP settings - Variables to send Taiga's emails to the users
EMAIL_BACKEND=console  # use an SMTP server or display the emails in the console (either "smtp" or "console")
EMAIL_HOST=smtp.host.example.com  # SMTP server address
EMAIL_PORT=587   # default SMTP port
EMAIL_HOST_USER=user  # user to connect the SMTP server
EMAIL_HOST_PASSWORD="rcBgqoD@C94#N4YTz!qK6&#BLz8EHkJ36j6X\$md&"  # SMTP user's password
[email protected]  # default email address for the automated emails
# EMAIL_USE_TLS/EMAIL_USE_SSL are mutually exclusive (only set one of those to True)
EMAIL_USE_TLS=True  # use TLS (secure) connection with the SMTP server
EMAIL_USE_SSL=False  # use implicit TLS (secure) connection with the SMTP server

# Taiga's RabbitMQ settings - Variables to leave messages for the realtime and asynchronous events
RABBITMQ_USER=taiga  # user to connect to RabbitMQ
RABBITMQ_PASS="oifecmah@B3QTSymYNYR9atmk4rEfSh66G64f&5a"  # RabbitMQ user's password
RABBITMQ_VHOST=taiga  # RabbitMQ container name
RABBITMQ_ERLANG_COOKIE=secret-erlang-cookie  # unique value shared by any connected instance of RabbitMQ

# Taiga's Attachments - Variable to define how long the attachments will be accesible
ATTACHMENTS_MAX_AGE=360  # token expiration date (in seconds)

# Taiga's Telemetry - Variable to enable or disable the anonymous telemetry
ENABLE_TELEMETRY=False

Output of createsuperuser

+ exec docker compose -f docker-compose.yml -f docker-compose-inits.yml run --rm taiga-manage createsuperuser
time="2025-03-31T23:11:03-05:00" level=warning msg="/home/jpaugh/proj/opc/taiga-docker/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"
time="2025-03-31T23:11:03-05:00" level=warning msg="/home/jpaugh/proj/opc/taiga-docker/docker-compose-inits.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"
time="2025-03-31T23:11:03-05:00" level=warning msg="Found orphan containers ([taiga-docker-penpot-frontend-1 taiga-docker-penpot-backend-1 taiga-docker-penpot-postgres-1 taiga-docker-penpot-exporter-1 taiga-docker-penpot-redis-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up."
 Container taiga-docker-taiga-db-1  Running
Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
    connection = Database.connect(**conn_params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server at "taiga-db" (172.19.0.6), port 5432 failed: FATAL:  password authentication failed for user "taiga"


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/taiga-back/manage.py", line 17, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/venv/lib/python3.11/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/venv/lib/python3.11/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/core/management/base.py", line 397, in execute
    self.check_migrations()
  File "/opt/venv/lib/python3.11/site-packages/django/core/management/base.py", line 486, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 53, in __init__
    self.build_graph()
  File "/opt/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 214, in build_graph
    self.load_disk()
  File "/opt/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 116, in load_disk
    migration_module = import_module(migration_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/taiga-back/taiga/projects/migrations/0046_triggers_to_update_tags_colors.py", line 50, in <module>
    class Migration(migrations.Migration):
  File "/taiga-back/taiga/projects/migrations/0046_triggers_to_update_tags_colors.py", line 86, in Migration
    migrations.RunSQL(_get_agg_array_agg_mult()),
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/taiga-back/taiga/projects/migrations/0046_triggers_to_update_tags_colors.py", line 16, in _get_agg_array_agg_mult
    pg_version = connection.cursor().connection.server_version
                 ^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 259, in cursor
    return self._cursor()
           ^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 235, in _cursor
    self.ensure_connection()
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 218, in ensure_connection
    with self.wrap_database_errors:
  File "/opt/venv/lib/python3.11/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
    self.connect()
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
    connection = Database.connect(**conn_params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: connection to server at "taiga-db" (172.19.0.6), port 5432 failed: FATAL:  password authentication failed for user "taiga"

jpaugh avatar Apr 01 '25 04:04 jpaugh

After some digging, I verified that I can use psl to connect to the db in the taiga-db service with the password in my .env file,

$ source .env
$ docker compose exec -e PGPASSWORD="$POSTGRES_PASSWORD" taiga-db psql -U $POSTGRES_USER -d taiga
psql (12.3 (Debian 12.3-1.pgdg100+1))
Type "help" for help.

taiga=#

and that the POSTGRES_PASSWORD environment variable is defined inside the taiga-manage service.

$ docker compose -f docker-compose.yml -f docker-compose-inits.yml run --rm taiga-manage shell
>>> import os
>>> os.getenv('POSTGRES_PASSWORD')
'YiNBtnoBcnh!8YzKfxr47'

jpaugh avatar Apr 01 '25 05:04 jpaugh

Okay, I figured out my issue when I realized that my previously-used superuser already existed. I needed to delete one or more of the the docker volume as well in order to rebuild from scratch and get it up and running. So, my "clean slate" script looks like this:

$ docker rm -f $(docker ps -aq)
$ docker volume rm $(docker volume ls)
$ docker rmi $(docker images -q)

Someone who uses docker every day might have figured it out sooner. On the other hand, it would be nice to see it in the docs.

jpaugh avatar Apr 01 '25 05:04 jpaugh

The commands above are very dangerous!!! They will delete all containers, images, etc. Do not use them if you have any other Docker projects.

I suggest the following commands:

docker compose -f docker-compose.yml down -v
docker rm $(docker ps -aq --filter "name=taiga")
docker rmi $(docker images "taigaio/*" -q)

Daniel-RUS avatar Oct 29 '25 07:10 Daniel-RUS