# Postgres DB configuration issue

**URL:** <https://farmos.discourse.group/t/postgres-db-configuration-issue/926>\
**Category:** Hosting farmOS\
**Created:** [September 15, 2021, 9:12am UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926 "2021-09-15T09:12:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raheel](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@raheel](https://farmos.discourse.group/u/raheel)\
**Post date:** [September 15, 2021, 9:12am UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/1 "2021-09-15T09:12:12Z")

</div>

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

 ![Screenshot_6](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/8a4eb381f1a33b40d0bec3dfef824a4c552d283a.png) 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
```

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 15, 2021, 11:54am UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/2 "2021-09-15T11:54:09Z")

</div>

> 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](https://docs.farmos.org/development/environment/#2-install-farmos)

> Advanced options \> Host: `db`

---

<div class="post-metadata">

**Author:** ![raheel](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@raheel](https://farmos.discourse.group/u/raheel)\
**Post date:** [September 17, 2021, 6:44am UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/4 "2021-09-17T06:44:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 17, 2021, 2:14pm UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/5 "2021-09-17T14:14:16Z")

</div>

> 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](https://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container)

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!

---

<div class="post-metadata">

**Author:** ![raheel](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@raheel](https://farmos.discourse.group/u/raheel)\
**Post date:** [September 18, 2021, 6:15am UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/6 "2021-09-18T06:15:54Z")

</div>

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.

 ![Screenshot_10](https://global.discourse-cdn.com/free1/uploads/farm_os/original/1X/297a27878944ce5470dc4c08af745185c6dd6d52.png)

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).

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [September 20, 2021, 12:54pm UTC](https://farmos.discourse.group/t/postgres-db-configuration-issue/926/7 "2021-09-20T12:54:23Z")

</div>

> 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/](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).

> **[Getting started](https://farmos.org/development/environment/)**
>
> farmOS is a free and open source web-based application for farm management, planning, and record keeping.

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