2016-08-11 202 views
1

我在本地Windows 7 x64计算机上运行了Postgres 9.5.3无法通过名称连接到本地计算机

当我连接到“localhost”时,我的代码工作正常。 如果我的名字连接到我的机器,我得到这个错误:

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 

很明显它试图与IPV6取代IPV4连接,还等什么?

pg_hba.conf看起来是这样的:

# 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 

任何帮助感激地接受

回答

2

如果您需要的特定地址来解决这个行添加到您的文件:

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

然而, LAN访问将此行添加到pg_hba.conf文件中的IPv6本地连接:

host all all fe80::/10 md5 

IPv6中以fe80::开头的地址是链路本地地址,仅用于本地网络的一个网段或点到点连接类型内的通信。他们不能通过互联网/不同的子网路由。

+0

非常感谢 - 这让我感到满足。 –

+0

确保你在地址中用'/'替换'%'...至少如果你从PGAdmin错误信息中得到它...... – DPSSpatial