Search code examples
linuxdockerodoo

Odoo container : Database connection failure: could not connect to server: Connection refused (linking odoo with localhost postgres)



I'm trying to run the odoo docker container and linking it with my local (not container) postgresql.
I tried this command (as suggest here).

docker container run -p 8089:8069 -e HOST=127.0.0.1 -e USER=tux -e PASSWORD=tux --name odoo -t odoo

Ran it and got these errors :

Database connection failure: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

I tried to open up the port 5432 with ufw but got the same erros. I also tried to change 127.0.0.1 to 0.0.0.0 but nothing.
Could you help me?

ps : the USER and PASSWORD are corrects, I use them when I run odoo instance in my local.


Solution

  • you might need to add the host network with a flag --network=host

    WARNING: Published ports are discarded when using host network mode that just means you cannot change the port bindings. thats as secure as your machine is.