Reputation: 983
I have installed postgresql on local and want to connect my docker instance to it.
The docker run command includes:
run:
IMAGE=$(IMAGE) CONFIG=$(config) docker-compose -f docker-compose.yml up -d
local:
@make build
@echo "\nCreate docker container.."
@make run config=$(config)
@echo "\n$(GREEN)Done.$(NO_COLOR)\n"
@echo "Try pallet at http://localhost:8080."
@echo "and flower at http://localhost:5555."
POSTGRES_HOST=192.168.0.142:5432
POSTGRES_PORT=5432
POSTGRES_CREDS=pallet:pallet
These are the settings from docker and an environment file, respectively.
The docker build is successful but I am getting the following error:
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.OperationalError) FATAL: no pg_hba.conf entry for host "172.21.0.2", user "pallet", database "airflow", SSL on
FATAL: no pg_hba.conf entry for host "172.21.0.2", user "pallet", database "airflow", SSL off
I have already changed the configuration files:
# - Connection Settings -
listen_addresses = '0.0.0.0' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
# - Security and Authentication -
#authentication_timeout = 1min # 1s-600s
ssl = true # (change requires restart)
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
# (change requires restart)
#ssl_prefer_server_ciphers = on # (change requires restart)
#ssl_ecdh_curve = 'prime256v1' # (change requires restart)
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' # (change requires restart)
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires restart)
#ssl_ca_file = '' # (change requires restart)
#ssl_crl_file = '' # (change requires restart)
#password_encryption = on
#db_user_namespace = off
#row_security = on
# GSSAPI using Kerberos
#krb_server_keyfile = ''
#krb_caseins_users = off
# - TCP Keepalives -
# see "man 7 tcp" for details
#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
# 0 selects the system default
#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
# 0 selects the system default
#tcp_keepalives_count = 0 # TCP_KEEPCNT;
# 0 selects the system default
And the lines are already added:
#hostssl "airflow" "pallet" '*' md5
#hostnossl "airflow" "pallet" '*' md5
host all all '*' trust
Yes, I did uncomment and then ran each of them in the file /etc/postgresql/9.5/main/pg_hba.conf
Upvotes: 2
Views: 3856
Reputation: 2391
Add the following line to pg_hba.conf
host all all all trust
or more specific if you like.
The error message shows very clear that the host ip is not allowed.
Upvotes: 3