Odoo 12 in WSL - Psycopg2 doesn't get the right Port for PostgreSQL

眉间皱痕 提交于 2019-12-13 17:42:07

问题


I have installed Odoo 12 in Ubuntu 18.04 LTS using WSL for windows 10 Pro.

Everything seems fine and service is running, but when I access the localhost I get Internal Server Error, and I get this error:

    2019-09-05 06:52:07,596 309 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 303, in run_wsgi
    execute(self.server.app)
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/serving.py", line 291, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/odoo/odoo/service/server.py", line 409, in app
    return self.app(e, s)
  File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 128, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1320, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1293, in __call__
    return self.app(environ, start_wrapped)
  File "/opt/odoo/.local/lib/python3.6/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/odoo/odoo/http.py", line 1453, in dispatch
    self.setup_db(httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1376, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1537, in db_monodb
    dbs = db_list(True, httprequest)
  File "/opt/odoo/odoo/odoo/http.py", line 1504, in db_list
    dbs = odoo.service.db.list_dbs(force)
  File "/opt/odoo/odoo/odoo/service/db.py", line 375, in list_dbs
    with closing(db.cursor()) as cr:
  File "/opt/odoo/odoo/odoo/sql_db.py", line 657, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 171, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 540, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/sql_db.py", line 608, in borrow
    **connection_info)
  File "/opt/odoo/.local/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? - - -

PostgreSQL is installed using port 5433:

Ver Cluster Port Status Owner    Data directory              Log file
10  main    5433 online postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log

I changed the port in the conf file \etc\odoo-server.conf from False to 5433:

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = 5433
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons

However, I get the same error. Seems Psycopg2 take the value as default port 5432 even I specified it in the .conf file.

Any help? Thanks


回答1:


Your distribution (like mine) probably makes the key in the /tmp directory. A quick workaround I've been using is:

mkdir /var/run/postgresql
ln -s /tmp/.s.PGSQL.5432(or 5433) /var/run/postgresql/


来源:https://stackoverflow.com/questions/57803034/odoo-12-in-wsl-psycopg2-doesnt-get-the-right-port-for-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!