Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Psycopg2 error: Cannot connect to database using Docker in Odoo 12

Subscribe

Get notified when there's activity on this post

This question has been flagged
databaseodoodockerodoo12v12
1 Reply
12521 Views
Avatar
Steven Deweirt

So I'm trying to start run my Odoo project. This has always worked in the past, but for some reason, afer restarting the host computer, it's giving me an error when I try to start up the project. I didn't change anything related to configuration so I'm stunned as to why it's giving me this error.

Here is the error:

2019-08-06 12:03:34,199 1 INFO ? odoo.sql_db: Connection to the database failed 
odoo_1  | 2019-08-06 12:03:34,202 1 INFO ? werkzeug: 192.168.0.249 - - [06/Aug/2019 12:03:34] "POST /longpolling/poll HTTP/1.1" 500 - 0 0.000 0.007
odoo_1  | 2019-08-06 12:03:34,209 1 ERROR ? werkzeug: Error on request:
odoo_1  | Traceback (most recent call last):
odoo_1  |   File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 205, in run_wsgi
odoo_1  |     execute(self.server.app)
odoo_1  |   File "/usr/lib/python3/dist-packages/werkzeug/serving.py", line 193, in execute
odoo_1  |     application_iter = app(environ, start_response)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 409, in app
odoo_1  |     return self.app(e, s)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 128, in application
odoo_1  |     return application_unproxied(environ, start_response)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py", line 117, in application_unproxied
odoo_1  |     result = odoo.http.root(environ, start_response)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1318, in __call__
odoo_1  |     return self.dispatch(environ, start_response)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1291, in __call__
odoo_1  |     return self.app(environ, start_wrapped)
odoo_1  |   File "/usr/lib/python3/dist-packages/werkzeug/wsgi.py", line 599, in __call__
odoo_1  |     return self.app(environ, start_response)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1451, in dispatch
odoo_1  |     self.setup_db(httprequest)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1374, in setup_db
odoo_1  |     httprequest.session.db = db_monodb(httprequest)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1535, in db_monodb
odoo_1  |     dbs = db_list(True, httprequest)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/http.py", line 1502, in db_list
odoo_1  |     dbs = odoo.service.db.list_dbs(force)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/service/db.py", line 375, in list_dbs
odoo_1  |     with closing(db.cursor()) as cr:
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 657, in cursor
odoo_1  |     return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 171, in __init__
odoo_1  |     self._cnx = pool.borrow(dsn)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 540, in _locked
odoo_1  |     return fun(self, *args, **kwargs)
odoo_1  |   File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 608, in borrow
odoo_1  |     **connection_info)
odoo_1  |   File "/usr/local/lib/python3.5/dist-packages/psycopg2/__init__.py", line 126, in connect
odoo_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
odoo_1  | psycopg2.OperationalError: could not translate host name "db" to address: Name or service not known - - -

My dockerfile


USER root

RUN pip3 install qrcode xlrd==1.2.0 xlwt XlsxWriter
RUN pip3 install --upgrade pip
RUN apt update && apt install -y cups libcups2-dev python3-dev patch && pip3 install pycups
RUN pip install psycopg2-binary
RUN apt-get update

USER odoo

My docker-compose


version: '2'
services:
db:
image: postgres:10
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
odoo:
build: .
depends_on:
- db
ports:
- "80:8069"
volumes:
- ./odoo.conf:/etc/odoo/odoo.conf
- .:/mnt/repo
- ./generator3.py:/opt/.pycharm_helpers/generator3.py

Thanks in advance for any help!

0
Avatar
Discard
Avatar
Paresh Wagh
Best Answer

Hi Brent: Your database container may not have started. Type in docker ps and see if the container db has started. 

0
Avatar
Discard
Steven Deweirt
Author

Hi, the docker container was running. I started the program up today and the it worked, but it doesn't find back my db anymore? any tips?

Steven Deweirt
Author

Scratch that, ended up having to restore my previous backup of the database to make it work. Probably should've taken a snapshot before trying stuff :)

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
psycopg2.ProgrammingError: no existe la relación «_unknown» Please HELP!!!!
odoo odoo12
Avatar
Avatar
2
Nov 25
414
How to clear cache after change data_dir path
odoo docker
Avatar
Avatar
1
Jun 25
12226
clean purchase history
database odoo
Avatar
Avatar
1
Mar 24
2495
How to track One2many field in Odoo12? Solved
odoo odoo12
Avatar
Avatar
Avatar
Avatar
3
Nov 23
18552
Error: Couldn't load module web Solved
odoo odoo12
Avatar
Avatar
Avatar
3
Nov 24
26681
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now