This might seem trivial, but how can I connect one machine ('A') to another machine's ('B') so that databases in 'A' and 'B' are synced at all times. Both machines run on macOS High Sierra and PostgreSQL v10 was installed with homebrew. Basically, I want 'A' to be a client of 'B' - which acts as the server and 'A' should be able to modify the database in 'B' and that changes are seen in both. I enabled ssh connections on 'B'. I modified the postgresql.conf and pg_hba.conf according to several online fixes in 'B'.
However, I get always the same error in my shell in 'A':
$ psql -h [ip 'B'] -p 5432 -U devil -W test_db
psql: FATAL: no pg_hba.conf entry for host "ip 'A'", user "devil", database "test_db", SSL off
PostgreSQL files in 'B' (directory: /usr/local/var/postgres):
In postgresql.conf [excerpt]:
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # 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)
In pg_hba.conf [excerpt] - which I cp from a file called pg_hba.conf.sample in the same folder:
# TYPE DATABASE USER ADDRESS METHOD
@remove-line-for-nolocal@ # "local" is for Unix domain socket
connections only
@remove-line-for-nolocal@
local all all
@authmethodlocal@
# IPv4 local connections:
host all all 127.0.0.1/32
@authmethodlocal@
# IPv6 local connections:
host all all ::1/128
@authmethodlocal@
# Allow replication connections from localhost, by a user with the
# replication privilege.
@remove-line-for-nolocal@local replication all
@authmethodlocal@
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all 0.0.0.0/0 md5#ipv4 range
I restarted the server with:
$ brew services restart postgresql