Обсуждение: remapped localhost causes connections to localhost to fail using Postgres

Поиск
Список
Период
Сортировка

remapped localhost causes connections to localhost to fail using Postgres

От
Dann Corbit
Дата:
<div class="WordSection1"><p class="MsoNormal">Using a Windows computer, editing the file:<p
class="MsoNormal">C:\WINDOWS\system32\drivers\etc\hosts<pclass="MsoNormal">the localhost entry was remapped to the
machinename by adding the following line:<p class="MsoNormal">127.0.0.1       <Computer-Name><p
class="MsoNormal"> <pclass="MsoNormal">After this change, Postgres would not allow access using the address
localhost.<pclass="MsoNormal">Only using the machine name to access the database was possible.<p class="MsoNormal">Is
thisby design?<p class="MsoNormal"> <p class="MsoNormal">In other words<p class="MsoNormal">psql -h localhost <p
class="MsoNormal">fails,but:<p class="MsoNormal">psql -h <Computer-Name> <p class="MsoNormal">succeeds.<p
class="MsoNormal"> </div>

Re: remapped localhost causes connections to localhost to fail using Postgres

От
Bill Moran
Дата:
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