Adam Benson
Adam Benson

Reputation: 8562

Cannot connect to local machine by name

I have Postgres 9.5.3 running on my local Windows 7 x64 machine.

When I connect to "localhost" my code works fine. If I connect to my machine by name I get this error:

Opening connection to 'W7_Adam_Benson' on port 5432 as user 'postgres'
ERROR: Devart.Data.PostgreSql.PgSqlException (0x80004005): no pg_hba.conf entry for host "fe80::6d80:62eb:5bab:f7f6%10", user "postgres", database "postgres", SSL off

It's obvious it's trying to connect with IPV6 instead of IPV4, but so what?

My pg_hba.conf looks like this:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             0.0.0.0/0               md5
host    all             all             127.0.0.1/32            md5

# IPv6 local connections:
host    all             all             ::1/128                 md5
host    all             all             *                       md5

# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host     all     all     *   trust

Any help gratefully received

Upvotes: 1

Views: 317

Answers (1)

Kamil Gosciminski
Kamil Gosciminski

Reputation: 17177

If you need the specific address to work add this line to your file:

host  all  all  fe80::6d80:62eb:5bab:f7f6/10  md5

However, for LAN access add this line to IPv6 local connections in pg_hba.conf file:

host  all  all  fe80::/10  md5

Adresses in IPv6 that start with fe80:: are link-local addresses which are used only for communication in one segment of local network or within connection type point-to-point. They can't be routed across the internet/different subnets.

Upvotes: 2

Related Questions