I have a clean install of Windows 10 Pro x64 and I’m trying to run PostgreSQL server on it. It used to work perfectly on Windows 7, but Windows 10 is behaving really weird: If I configure PostgreSQL to listen on 127.0.0.1
then I can't connect to it using psql:
psql: could not connect to server: Permission denied (0x0000271D/10013)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
But if I change it to listen on 192.168.0.108 (my intranet ip) then everything works:
>psql.exe --host=192.168.0.108 --username=test test
psql (9.4.0)
Same behavior (meaning PostgreSQL works fine) is if I tell it to listen to localhost
as a name instead of IP, although in both cases (either localhost
or 127.0.0.1
) it listens exactly on the same IP and port:
>netstat -abno | grep 5432 -A 1
TCP 127.0.0.1:5432 0.0.0.0:0 LISTENING 3480
[postgres.exe]
--
TCP [::1]:5432 [::]:0 LISTENING 3480
[postgres.exe]
There’s nothing in my C:\Windows\System32\drivers\etc\hosts
. And I don’t think the problem is specific to PostgreSQL, I just used it as an example. I have other services running locally which have the same problem - can’t connect to local socket because of permissions error.
localhost
. Bonjour/AVAHI and other Zero-conf services can map other loopback addresses to names likemybox.local
. It is also possible that IPv6 is muddying the waters, so consider disabling it if it is unneeded.