Search code examples
pythonpostgresqlodoo-8

How do I fix connecting to Postgres


I having a problem connecting to postgres whenever I try to run the odoo for development. Here are the logs I have so far. When I try to run psql I also get the following:

psql: 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"?

Logs

2017-11-18 06:43:55,364 4941 INFO ? openerp: OpenERP version 8.0
2017-11-18 06:43:55,364 4941 INFO ? openerp: addons paths: ['/home/pmutua/.local/share/Odoo/addons/8.0', u'/opt/odoo/openerp/addons', u'/opt/odoo/addons']
2017-11-18 06:43:55,364 4941 INFO ? openerp: database hostname: localhost
2017-11-18 06:43:55,365 4941 INFO ? openerp: database port: 5432
2017-11-18 06:43:55,365 4941 INFO ? openerp: database user: pmutua
2017-11-18 06:43:55,567 4941 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2017-11-18 06:44:06,200 4941 ERROR None openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:06,234 4941 ERROR None openerp.http: 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"?
Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:06,327 4941 INFO ? openerp.addons.bus.bus: Bus.loop listen imbus on db postgres
2017-11-18 06:44:06,327 4941 ERROR ? openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:06,327 4941 ERROR ? openerp.addons.bus.bus: Bus.loop error, sleep and retry
Traceback (most recent call last):
  File "/opt/odoo/addons/bus/bus.py", line 136, in run
    self.loop()
  File "/opt/odoo/addons/bus/bus.py", line 114, in loop
    with openerp.sql_db.db_connect('postgres').cursor() as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:06,455 4941 INFO None werkzeug: 127.0.0.1 - - [18/Nov/2017 06:44:06] "GET /robots.txt HTTP/1.1" 500 -
2017-11-18 06:44:06,582 4941 ERROR None werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 168, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/openerp/service/server.py", line 294, in app
    return self.app(e, s)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1299, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1424, in dispatch
    self.setup_db(httprequest)
  File "/opt/odoo/openerp/http.py", line 1359, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "/opt/odoo/openerp/http.py", line 1496, in db_monodb
    dbs = db_list(True, httprequest)
  File "/opt/odoo/openerp/http.py", line 1470, in db_list
    dbs = dispatch_rpc("db", "list", [force])
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?
2017-11-18 06:44:06,982 4941 INFO ? openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2017-11-18 06:44:07,265 4941 INFO ? openerp.http: HTTP Configuring static files
2017-11-18 06:44:07,267 4941 ERROR None openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:07,267 4941 ERROR None openerp.http: 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"?
Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:07,269 4941 INFO None werkzeug: 127.0.0.1 - - [18/Nov/2017 06:44:07] "GET / HTTP/1.1" 500 -
2017-11-18 06:44:07,279 4941 ERROR None werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 168, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/openerp/service/server.py", line 294, in app
    return self.app(e, s)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1299, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1273, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 591, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1424, in dispatch
    self.setup_db(httprequest)
  File "/opt/odoo/openerp/http.py", line 1359, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "/opt/odoo/openerp/http.py", line 1496, in db_monodb
    dbs = db_list(True, httprequest)
  File "/opt/odoo/openerp/http.py", line 1470, in db_list
    dbs = dispatch_rpc("db", "list", [force])
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?
2017-11-18 06:44:07,426 4941 ERROR None openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:07,426 4941 ERROR None openerp.http: 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"?
Traceback (most recent call last):
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?

2017-11-18 06:44:07,428 4941 INFO None werkzeug: 127.0.0.1 - - [18/Nov/2017 06:44:07] "GET /robots.txt HTTP/1.1" 500 -
2017-11-18 06:44:07,433 4941 ERROR None werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 168, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/openerp/service/server.py", line 294, in app
    return self.app(e, s)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1299, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1273, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 591, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1424, in dispatch
    self.setup_db(httprequest)
  File "/opt/odoo/openerp/http.py", line 1359, in setup_db
    httprequest.session.db = db_monodb(httprequest)
  File "/opt/odoo/openerp/http.py", line 1496, in db_monodb
    dbs = db_list(True, httprequest)
  File "/opt/odoo/openerp/http.py", line 1470, in db_list
    dbs = dispatch_rpc("db", "list", [force])
  File "/opt/odoo/openerp/http.py", line 115, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/openerp/service/db.py", line 73, in dispatch
    return fn(*params)
  File "/opt/odoo/openerp/service/db.py", line 313, in exp_list
    with closing(db.cursor()) as cr:
  File "/opt/odoo/openerp/sql_db.py", line 622, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
  File "/opt/odoo/openerp/sql_db.py", line 194, in __init__
    self._cnx = pool.borrow(dsn)
  File "/opt/odoo/openerp/sql_db.py", line 511, in _locked
    return fun(self, *args, **kwargs)
  File "/opt/odoo/openerp/sql_db.py", line 573, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
  File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
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"?
^C2017-11-18 06:44:23,543 4941 INFO ? openerp.service.server: Initiating shutdown
2017-11-18 06:44:23,544 4941 INFO ? openerp.service.server: Hit CTRL-C again or send a second signal to force the shutdown.

Solution

  • I re-installed postgres and followed the following instructions and it worked.

    https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04