无法按名称连接到本地计算机

Cannot connect to local machine by name

我的本地 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

感谢收到的任何帮助

如果您需要特定地址才能工作,请将此行添加到您的文件中:

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

但是,对于 LAN 访问,将此行添加到 pg_hba.conf 文件中的 IPv6 本地连接:

host  all  all  fe80::/10  md5

IPv6 中以 fe80:: 开头的地址是 link-本地地址,仅用于本地网络的一个网段或点对点连接类型中的通信。它们无法跨 internet/different 个子网路由。