Re: remapped localhost causes connections to localhost to fail using Postgres - Mailing list pgsql-hackers

From Bill Moran
Subject Re: remapped localhost causes connections to localhost to fail using Postgres
Date
Msg-id 20151204171638.98ff11e91957357099ece0b4@potentialtech.com
Whole thread Raw
In response to remapped localhost causes connections to localhost to fail using Postgres  (Dann Corbit <DCorbit@connx.com>)
List pgsql-hackers
On Fri, 4 Dec 2015 21:55:23 +0000
Dann Corbit <DCorbit@connx.com> wrote:

> Using a Windows computer, editing the file:
> C:\WINDOWS\system32\drivers\etc\hosts
> the localhost entry was remapped to the machine name by adding the following line:
> 127.0.0.1       <Computer-Name>
> 
> After this change, Postgres would not allow access using the address localhost.
> Only using the machine name to access the database was possible.
> Is this by design?
> 
> In other words
> psql -h localhost
> fails, but:
> psql -h <Computer-Name>
> succeeds.

This has nothing to do with Postgres. This is the behavior of the operating
system. I expect that you'll find that no program on the machine is able to
connect using the string "localhost" any more. psql is simply using the
OS' builtin name resolution, and you told that name resolution that there
is no longer a machine named localhost.

On posix systems, it's cusomary to put multiple names in the hosts file,
localhost included. I expect that Windows is the same, but I haven't used
it in so long that I can't be sure.

-- 
Bill Moran



pgsql-hackers by date:

Previous
From: Dann Corbit
Date:
Subject: remapped localhost causes connections to localhost to fail using Postgres
Next
From: Jim Nasby
Date:
Subject: Re: Size of Path nodes