I’m building my stack with nginx, php-fpm and postgres.
PHP is already working with nginx. But I can’t connect to postgres.
This is the (partial) code in my docker-compose file (version 2)
postgresql: image: postgres container_name: postgres-stubb ports: - "5431:5432" environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=d4REn0LdCH4B volumes: - ./env-config/postgres.conf:/etc/postgresql.conf - /srv/docker/postgresql:/var/lib/postgresql command: postgres -c config_file=/etc/postgresql.conf restart: always
Basically, I’m using the official image and mapping to 5432. At first, I tried 5432:5432 but then I changed to 5431:5432 just to try something different. Neither work.
My postgresql.conf file was taken from the postgres image and says:
listen_addresses = '*'
Through my other containers I’m running Laravel 5 with this config:
DB_HOST=127.0.0.1 DB_PORT=5431 DB_DATABASE=postgres DB_USERNAME=postgres DB_PASSWORD=d4REn0LdCH4B
And the error is:
SQLSTATE  could not connect to server: Connection refused
Is the server running on host “127.0.0.1” and accepting
TCP/IP connections on port 5431? (SQL: select * from “cards”)
I spent the whole day trying to solve this with no luck. Any clue?