sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: password authentication failed for user "opencve"
hktalent opened this issue · 2 comments
hktalent commented
$ docker-compose up -d postgres redis webserver celery_worker
is ok
$ docker exec -it webserver opencve upgrade-db
docker exec -it webserver opencve upgrade-db
Traceback (most recent call last):
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 294, in unique_connection
return _ConnectionFairy._checkout(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 751, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 483, in checkout
rec = pool._do_get()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 237, in _do_get
return self._create_connection()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 299, in _create_connection
return _ConnectionRecord(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 428, in __init__
self.__connect(first_connect_check=True)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 630, in __connect
connection = pool._invoke_creator(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/app/venv/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "opencve"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/venv/bin/opencve", line 11, in <module>
load_entry_point('opencve==1.2.3', 'console_scripts', 'opencve')()
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/opencve/commands/__init__.py", line 39, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/flask/cli.py", line 412, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/opencve/commands/upgrade_db.py", line 16, in upgrade_db
upgrade(directory=str(migrations_path))
File "/app/venv/lib/python3.7/site-packages/flask_migrate/__init__.py", line 92, in wrapped
f(*args, **kwargs)
File "/app/venv/lib/python3.7/site-packages/flask_migrate/__init__.py", line 162, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/venv/lib/python3.7/site-packages/alembic/command.py", line 320, in upgrade
script.run_env()
File "/app/venv/lib/python3.7/site-packages/alembic/script/base.py", line 563, in run_env
util.load_python_file(self.dir, "env.py")
File "/app/venv/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file
module = load_module_py(module_id, path)
File "/app/venv/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/venv/lib/python3.7/site-packages/opencve/migrations/env.py", line 94, in <module>
run_migrations_online()
File "/app/venv/lib/python3.7/site-packages/opencve/migrations/env.py", line 76, in run_migrations_online
connection = engine.connect()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2193, in connect
return self._connection_cls(self, **kwargs)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 103, in __init__
else engine.raw_connection()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2293, in raw_connection
self.pool.unique_connection, _connection
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2266, in _wrap_pool_connect
e, dialect, self
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 294, in unique_connection
return _ConnectionFairy._checkout(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 751, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 483, in checkout
rec = pool._do_get()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 237, in _do_get
return self._create_connection()
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 299, in _create_connection
return _ConnectionRecord(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 428, in __init__
self.__connect(first_connect_check=True)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 630, in __connect
connection = pool._invoke_creator(self)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/app/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/app/venv/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: password authentication failed for user "opencve"
(Background on this error at: http://sqlalche.me/e/e3q8)
ldurnez commented
Hello,
Did you change the postgresql password in .env file after starting postgres docker? Is it working with the default password?
As the postgresql data folder is a docker volume, the password is set with default values if there is none in .env file at the first boot of the instance. If you change it later, you need to update it directly in postgresql database.
Related issue: opencve/opencve#95
FanchenBao commented
In my case, I forgot to update the database_uri
content in opencve.cfg
. The URI is in the format of postgresql://user:secret@localhost:5432/dbname
. If using a custom password, the secret
in the URI must be updated.