Postgres DB configuration issue

I was trying to deploy the FarmOS 2.x on docker on the configuration i got the following issue

i’m giving the credentials and the DB name and its on the default “localhost/127.0.0.1” and on default port but still i am getting this error. In the development .yml file i only changed the credentials database.

environment:

  POSTGRES_USER: postgres

  POSTGRES_PASSWORD: postgres

  POSTGRES_DB: farm
1 Like

and its on the default “localhost/127.0.0.1”

If you are running PostgreSQL in a separate Docker container (eg: using the recommended docker-compose.development.yml configuration), then the database is not on localhost (which is the farmOS container, in that context), it is db.

See step 2 in the development environment setup instructions: https://docs.farmos.org/development/environment/#2-install-farmos

Advanced options > Host: db

1 Like

ON production.yml it only install the docker container for website and you have to give the credentials of local DB, i am trying to give the credentials but i am getting the error i attached the screenshot above.Postgres is hosted on localhot and port 5432, when i give that it show that error i mentioned above.

1 Like

Postgres is hosted on localhot and port 5432

TL;DR: Try using host.docker.internal (if you are running Docker on Mac or Windows)

More details…

localhost is always relative to the system you’re running it in. When farmOS is in Docker, then localhost essentially means “the same system as farmOS” - but that’s not where the database is installed.

It sounds like you have the database installed on the host system (alongside the Docker container that farmOS is running in). From the perspective of the host system, the database is on localhost, but from the perspective of farmOS (running in Docker), the database is NOT running on localhost, it’s running on the host system, which will have an IP address set by Docker.

The reason we don’t include a database service in the production docker-compose.yml template is because we leave it up to the administrator to decide where they want to host the database. Running it in Docker, like the development template does, make it easy to reference the database host because Docker will make the service name (db) available as a hostname in all the Docker services. Running it on a separate server is also easy, because you can reference that server’s public hostname. Running it on the host server while farmOS is in Docker is tricky because you need to figure out what IP address Docker assigned to the host.

This StackOverflow question might be useful: How to get the IP address of the docker host from inside a docker container - Stack Overflow

If you are running on Mac/Windows, this is actually pretty easy. Just use host.docker.internal.

Linux doesn’t have a handy shortcut like that, unfortunately.

Hope that helps!

2 Likes

First of all i want to thank you for your support all this time, second it got deployed on docker window but when i add a person in my farm from admin account the user get created but the i get error that email to the person i added didn’t sent.

I also need to know i tried to deploy farmOS 2.x on linux through docker i get some permission error on docker-compose up command, is there a proper guide like how to deploy it on linux(Ubuntu).

1 Like

when i add a person in my farm from admin account the user get created but the i get error that email to the person i added didn’t sent.

Ah yes - the Docker containers do not handle email. But we have some instructions here that outline your options: https://docs.farmos.org/hosting/email/

i tried to deploy farmOS 2.x on linux through docker i get some permission error on docker-compose up command

Can you share the permission error that you experienced?

is there a proper guide like how to deploy it on linux(Ubuntu).

The official docs are tested to work on Linux (I use Ubuntu myself for all local development and testing).

But if there are issues with the docs we should fix them! Any details you can provide on the issue you encountered are appreciated!