From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Cannot connect to postgresql-11 from another machine after boot
Date: Sun, 16 Feb 2020 14:51:21 +0100
Message-ID: <20200216135121.GA10553@hjp.at> (raw)
In-Reply-To: <b9f567c2-26e9-4ffe-1630-d7994e32c673@aklaver.com>
References: <CAEk9e3pcmikJRo6cQ0COHpu_Z9gLLUeX=tY1w1qOVpzUehCB9A@mail.gmail.com>
<4e04fcba-2921-df12-c1a5-7a3eb5afb1eb@aklaver.com>
<b9f567c2-26e9-4ffe-1630-d7994e32c673@aklaver.com>
On 2020-02-13 21:03:48 -0800, Adrian Klaver wrote:
> On 2/13/20 9:02 PM, Adrian Klaver wrote:
> > On 2/13/20 7:54 PM, Jason Swails wrote:
> > > The problem is that after my machine boots, I'm unable to connect to
> > > the server from anywhere except localhost. Running a simple
> > > "systemctl restart postgresql" fixes the problem and allows me to
> > > connect from anywhere on my LAN. Here is an example of this
> > > behavior:
[...]
> > >
> > > So the first connection attempt fails. But when I restart the
> > > service and try again (doing nothing else in between), the
> > > connection attempt succeeds. My workaround has been to simply
> > > restart the service every time my machine reboots, but I'd really
> > > like to have a more reliable startup.
> > >
> > > Any ideas how to start hunting down the root cause? I think this
> > > started happening after I moved the data directory to another drive.
> >
> > I would start by looking in the system log to see what it records when
> > the service tries to start on reboot.
>
> Hit send to soon. At a guess the Postgres service is starting before the
> drive is mounted.
I don't think this has anything to do with the drive. If the drive
wasn't mounted he couldn't connect from localhost either.
What is probably happening is that postgresql is configured to listen on
localhost and the IP address of the ethernet interface and is starting
before the etherned interface is ready. So it is listening only on
localhost (there should be an error message regarding the other address
in the log). When he restarts postgresql some time later, the interface
is ready.
It should be possible to solve this by adding the right dependencies to systemd.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: hjp-pgsql@hjp.at
Subject: Re: Cannot connect to postgresql-11 from another machine after boot
In-Reply-To: <20200216135121.GA10553@hjp.at>
References: <CAEk9e3pcmikJRo6cQ0COHpu_Z9gLLUeX=tY1w1qOVpzUehCB9A@mail.gmail.com> <4e04fcba-2921-df12-c1a5-7a3eb5afb1eb@aklaver.com> <b9f567c2-26e9-4ffe-1630-d7994e32c673@aklaver.com> <20200216135121.GA10553@hjp.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox