

Open /usr/local/var/postgres/nf and edit change listen_addresses: listen_addresses = '*' Open /usr/local/var/postgres/pg_hba.conf and add this line: host all all 10.200.10.1/24 trust
DOCKER 18.0.4 FOR MAC FOR MAC
But Docker for Mac does not expose the bridge network, so I had to do this trick to workaround the limitation: $ sudo ifconfig lo0 alias 10.200.10.1/24

Thanks to comment, now it is tons easier with this special Mac-only DNS name available: docker run -e DB_PORT=5432 -e DB_HOST=.internalįrom 17.12.0-cd-mac46, .internal should be used instead of. This means, if you want to grant access from all possible containers to your database, use 172.17.0.0/16. For each Docker container, a random address from that range will be assigned. The IP address is randomly assigned, but without any additional configuration, it will always be in the 172.17.0.0/16 network. This means that the network address is 172.17.0.0/16. Link/ether 56:84:7a:fe:97:99 brd ff:ff:ff:ff:ff:ffĪs you can see, in my case, the docker0 interface has the IP address 172.17.42.1 with a netmask of /16 (or 255.255.0.0). When Docker starts, it will create a new bridge network interface, that you can easily see when calling ip a: $ ip aģ: docker0: mtu 1500 qdisc noqueue state DOWN No Docker container will ever get that address assigned, because it's the network address of the Docker bridge ( docker0) interface. Look for the setting listen_addresses in PostgreSQL's configuration file, typically found in /etc/postgresql/9.3/main/nf (credits to versionġ72.17.0.0/32 is not a range of IP addresses, but a single address (namly 172.17.0.0). Make sure PostgreSQL is configured to listen for connections on all IP addresses, not just on localhost.To keep the container portable, start the container with the -add-host=database: flag and use database as hostname for connecting to PostgreSQL. Don't use localhost to connect to the PostgreSQL database on your host, but the host's IP instead.I had previously queried the IP address of the docker container using docker ps and although the IP address changes, it has so far always been in the range 172.17.0.xĪny ideas why I can't connect to this database? Probably something very simple I imagine!

The postgres server is running, and I've edited my pg_hba.conf file to allow connections from a range of IP addresses (172.17.0.0/32). I'm still getting an error message when I try and connect to my database running QGIS in Docker: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections to port 5433? I figure this is because my postgres database is not configured to accept remote connections and have been editing the postgres conf files to allow remote connections using the instructions in this article.

I've recently been playing around with Docker and QGIS and have installed a container following the instructions in this tutorial.Įverything works great, although I am unable to connect to a localhost postgres database that contains all my GIS data.
