2

Using Custom config file to run Odoo 13 but can't initiate database.

./odoo-bin --addons-path=odoo/addons -d odoo_codingdodo --save --config=.odoorc_codingdodo

I have updated all of my Homebrew packages, reinstalled Postgres but it's not helping me to fix this issue. I was working on Odoo 13 with another config file and I was using anaconda for python3.8,env etc... but once I upgrade my anaconda packages I can't able to work with it so I have removed all the anaconda packages and removed python3.9.. latest version and reinstalled as new and using Pyenv to setup my python Virtualenv. cloned Odoo 13 but I can't able to run with the custom config file.

Getting this error

2021-12-14 03:38:55,157 2939 INFO ? odoo: Odoo version 13.0 
2021-12-14 03:38:55,157 2939 INFO ? odoo: Using configuration file at /Users/thanseef/Odoo13/odoo/.odoorc_codingdodo 
2021-12-14 03:38:55,157 2939 INFO ? odoo: addons paths: ['/Users/thanseef/Odoo13/odoo/odoo/addons', '/Users/thanseef/Library/Application Support/Odoo/addons/13.0'] 
2021-12-14 03:38:55,157 2939 INFO ? odoo: database: default@default:default 
2021-12-14 03:38:55,164 2939 INFO ? odoo.sql_db: Connection to the database failed 
Traceback (most recent call last):
  File "/Users/thanseef/Odoo13/odoo/./odoo-bin", line 8, in <module>
    odoo.cli.main()
  File "/Users/thanseef/Odoo13/odoo/odoo/cli/command.py", line 60, in main
    o.run(args)
  File "/Users/thanseef/Odoo13/odoo/odoo/cli/server.py", line 178, in run
    main(args)
  File "/Users/thanseef/Odoo13/odoo/odoo/cli/server.py", line 142, in main
    odoo.service.db._create_empty_database(db_name)
  File "/Users/thanseef/Odoo13/odoo/odoo/service/db.py", line 98, in _create_empty_database
    with closing(db.cursor()) as cr:
  File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 664, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 196, in __init__
    self._cnx = pool.borrow(dsn)
  File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 547, in _locked
    return fun(self, *args, **kwargs)
  File "/Users/thanseef/Odoo13/odoo/odoo/sql_db.py", line 613, in borrow
    result = psycopg2.connect(
  File "/Users/thanseef/.pyenv/versions/odoo-13_env/lib/python3.9/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
  • You will need to add db_password = [pg_password] in your odoo configration file defualt password can be openpgpwd and if you have installed with script it can be odoo or odoo[version] if still not working you can change the odoo user password by checking the following link https://stackoverflow.com/questions/27107557/what-is-the-default-password-for-postgres – Muhammad Yusuf Dec 14 '21 at 04:34

1 Answers1

1

In case it helps anyone else that finds this, I resolved this error with the following:

  1. pip install python-dotenv
  2. Add the following imports:
import os
import sys
from dotenv import load_dotenv

load_dotenv()
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  1. Use os.getenv - Example (this feeds in saved environment variables in .env):
def db_conn():
    conn = psycopg2.connect(
        host=os.getenv("POSTGRES_HOST"),
        database=os.getenv("POSTGRES_DB"),
        user=os.getenv("POSTGRES_USER"),
        password=os.getenv("POSTGRES_PASSWORD")
    )
Tucker
  • 79
  • 8