patternsqlMinor
Connect to PostgreSQL from different host
Viewed 0 times
postgresqlconnectdifferenthostfrom
Problem
I am facing error while connecting to the PostgreSQL server from different host, I configured both
So I have installed PostgreSQL on Debian from package, added user with
And added this line in
Then I have restarted service and tried to connect from my machine via
So have I forgotten about something?
Whole
```
eth0 Link encap:Ethernet HWaddr 52:54:00:00:00:15
inet addr:10.10.30.83 Bcast:10.10.30.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe00:15/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU
postgresql.conf and pg_hba.conf but unfortunately with no result.So I have installed PostgreSQL on Debian from package, added user with
createuser and useradd, then created db via createdb as my custom user as an owner. Afterwards I have set postgresql.conf with these valueslisten_addresses = '*'
ssl = falseAnd added this line in
pg_hba.conf host all all 192.168.0.0/24 md5Then I have restarted service and tried to connect from my machine via
psql -U admin -d admin -h 10.10.30.88and I am getting this errorpsql: FATAL: no pg_hba.conf entry for host "192.168.10.195", user "admin", database "admin", SSL offSo have I forgotten about something?
Whole
pg_hba.conflocal all postgres peer
local all all peer
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
host all all 192.168.0.0/24 md5
host all all 10.10.0.0/24 md5ipconfig PostgreSQL servereth0 Link encap:Ethernet HWaddr 52:54:00:00:00:03
inet addr:10.10.30.88 Bcast:10.10.30.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe00:3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4001 errors:0 dropped:0 overruns:0 frame:0
TX packets:2297 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:365126 (356.5 KiB) TX bytes:306782 (299.5 KiB)ipconfig from other VM in same network```
eth0 Link encap:Ethernet HWaddr 52:54:00:00:00:15
inet addr:10.10.30.83 Bcast:10.10.30.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe00:15/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU
Solution
The issue is probably due to this line:
This (the
or
or
depending on what range of IPs you want to allow.
host all all 192.168.0.0/24 md5This (the
24) basically tells Postgres to allow connections from any machine that has IP of the form: 192.168.0.x. So, your 192.168.10.195 does not match the criteria. You can replace it with:host all all 192.168.0.0/16 md5 -- any 192.168.x.xor
host all all 192.168.10.0/24 md5 -- any 192.168.10.xor
host all all 192.168.10.195/32 md5 -- only 192.168.10.195depending on what range of IPs you want to allow.
Code Snippets
host all all 192.168.0.0/24 md5host all all 192.168.0.0/16 md5 -- any 192.168.x.xhost all all 192.168.10.0/24 md5 -- any 192.168.10.xhost all all 192.168.10.195/32 md5 -- only 192.168.10.195Context
StackExchange Database Administrators Q#128708, answer score: 6
Revisions (0)
No revisions yet.