Re: PostgreSQL doesn't accept connections when Windows

Lists: pgsql-general
From: George Weaver <gweaver(at)shaw(dot)ca>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: PostgreSQL doesn't accept connections when Windows Server is rebooted
Date: 2006-11-27 18:20:02
Message-ID: 009701c71250$a8427600$6400a8c0@Dell4500
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi everyone,

I recently installed PostgreSQL (Version 8.1.5.1) using the MSI installer on a Windows Server 2000 system.

I ran the installer logged in under an Administrator account, and set the service account to postgres.

During the installation process, when it came time to run initdb, the installer would stop with the error message:

"Failed to run initdb: 128. Please see the logfile in 'C:\Program Files\PostgreSQL\8.1\tmp\initdb.log.
Note! You must read/copy this logfile before you click OK, or it will be automatically removed."

I surmized that the problem was that I was attempting to run the install as an Administrator, so I addressed the problem by running the install, but not having the installer run initdb step to intialize the database cluster. When the install finished without error, I then logged onto the server under the postgres account and manually ran initdb. I was able to initialize the cluster.

I then updated the postgresql.conf file with "listen_addresses = '*' and changed the port from 5432 (currently being used for a 7.3 server) to 5435.

Everything runs as expected.

Until the Windows Server is rebooted. When this occurs, the PostgreSQL service starts as expected, but won't accept connections.

If the PostgreSQL service is then restarted manually (via Administrative Tools > Component Services > Restart), the service runs as expected and everything is normal.

How can I correct this?

Thanks in advance,
George


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: George Weaver <gweaver(at)shaw(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-11-27 18:28:11
Message-ID: 1164652091.16182.37.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


>
> Everything runs as expected.
>
> Until the Windows Server is rebooted. When this occurs, the
> PostgreSQL service starts as expected, but won't accept connections.
>
> If the PostgreSQL service is then restarted manually (via
> Administrative Tools > Component Services > Restart), the service runs
> as expected and everything is normal.
>
> How can I correct this?

By providing us with some logging output that tells us what PostgreSQL
is doing. :)

Sincerely,

Joshua D. Drake

>
> Thanks in advance,
> George
--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate


From: Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>
To: George Weaver <gweaver(at)shaw(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-11-27 18:41:45
Message-ID: 456B3169.9010101@amsoftwaredesign.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

George Weaver wrote:
>
> I then updated the postgresql.conf file with "listen_addresses = '*'
> and changed the port from 5432 (currently being used for a 7.3 server)
> to 5435.
>
Have you tried setting the port back to default and see what happens?
Is it possible for you to stop the 7.3 server for a moment to test this
theory?

The only thing you have different is the port, so I am thinking that it
has something to do with that.

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration


From: "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com>
To: "George Weaver" <gweaver(at)shaw(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows Server is rebooted
Date: 2006-11-27 19:29:54
Message-ID: 7be3f35d0611271129u3770e28l4d0a394329c720a3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

George,

I guess your service is not running after rebooting? You can check this via
services.msc

Most propable cause: the postgres user does not have logon_as_service
privilege.

I ran the installer logged in under an Administrator account, and set the
> service account to postgres.
>

That is the recommended way. The installer will create an low-priv postgres
service account and run initdb as that user.

During the installation process, when it came time to run initdb,
> the installer would stop with the error message:
>
> "Failed to run initdb: 128. Please see the logfile in 'C:\Program
> Files\PostgreSQL\8.1\tmp\initdb.log.
> Note! You must read/copy this logfile before you click OK, or it
> will be automatically removed."
>

Did you read that log? Read and copy it befor clicking OK, just as the
message stated?

BECAUSE: running THE INSTALLER as Administrator is recommended AND necessary
to create the postgres user and to give correct rights to this user.

SO: in running initdb.exe something else went wrong, it is NOT because you
ran the installer as Administrator.

(guessing .... you installed with port 5432, and initdb tried to contact
5432, failing, because it is an 7.3 ?)

If the PostgreSQL service is then restarted manually (via Administrative
> Tools > Component Services > Restart), the service runs as expected and
> everything is normal.
> How can I correct this?
>

One try to repair this: login as Administrator, open services.msc, and
from the postgreSQL service refill the login information. That does reset
the LOGON_AS_SERVICE privilege.

Harald

--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
Python: the only language with more web frameworks than keywords.


From: George Weaver <gweaver(at)shaw(dot)ca>
To: Harald Armin Massa <haraldarminmassa(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-11-27 21:42:19
Message-ID: 00e001c7126c$eb14b800$6400a8c0@Dell4500
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

----- Original Message -----
From: Harald Armin Massa

Hi Harald,

>I guess your service is not running after rebooting? You can check this via services.msc

This is what is confusing me - the service IS running after rebooting, but does not appear to be listening on port 5435. If I simply restart the service in the Administrative Tools > Component Services section everything is fine.

>>During the installation process, when it came time to run initdb, the installer would stop with the error message:

>> "Failed to run initdb: 128. Please see the logfile in 'C:\Program Files\PostgreSQL\8.1\tmp\initdb.log.
> > Note! You must read/copy this logfile before you click OK, or it will be automatically removed."

> Did you read that log? Read and copy it befor clicking OK, just as the message stated?

When I tried to (before clicking OK), there was no initdb.log file - or any other file - in the 'C:\Program Files\PostgreSQL\8.1\tmp\ directory.

>One try to repair this: login as Administrator, open services.msc, and from the postgreSQL service refill the login information. That does reset the LOGON_AS_SERVICE privilege.

I'll give this a try and see what happens.

George


From: "Harald Armin Massa" <haraldarminmassa(at)gmail(dot)com>
To: "George Weaver" <gweaver(at)shaw(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-11-28 05:51:39
Message-ID: 7be3f35d0611272151h409e86d5n94c60107558560f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

George,

>I guess your service is not running after rebooting? You can check this via
> services.msc
>
> This is what is confusing me - the service IS running after rebooting, but
> does not appear to be listening on port 5435. If I simply restart the
> service in the Administrative Tools > Component Services section everything
> is fine.
>
> Okay, that is a different situation. I was helping for the "serice not
running after reboot" :)

Can you please check the log files produced by the server? If PostgreSQL
started up successfully, there should be a new file in <data>\pg_log

(standard stderr redirection assumed)

whats in that ?

Harald

--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607
-
Python: the only language with more web frameworks than keywords.


From: Jim Nasby <decibel(at)decibel(dot)org>
To: Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>
Cc: George Weaver <gweaver(at)shaw(dot)ca>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-11-30 21:45:00
Message-ID: 8C595CB3-9714-40FF-923D-860280E97C5B@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Nov 27, 2006, at 10:41 AM, Tony Caduto wrote:
>> I then updated the postgresql.conf file with "listen_addresses =
>> '*' and changed the port from 5432 (currently being used for a 7.3
>> server) to 5435.
>>
> Have you tried setting the port back to default and see what happens?
> Is it possible for you to stop the 7.3 server for a moment to test
> this theory?
>
> The only thing you have different is the port, so I am thinking
> that it has something to do with that.

Hmm... are you sure there isn't already something listening on port
5435?
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)


From: George Weaver <gweaver(at)shaw(dot)ca>
To: Jim Nasby <decibel(at)decibel(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-12-01 13:17:45
Message-ID: 002a01c7154b$181b6ed0$6400a8c0@Dell4500
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


From: "Jim Nasby"

> Hmm... are you sure there isn't already something listening on port 5435?

Hi Jim,

How might I determine this?

Would this make a difference when the system is rebooted vs manually
restarting the server?

Thanks,
George


From: "Thomas H(dot)" <me(at)alternize(dot)com>
To: "George Weaver" <gweaver(at)shaw(dot)ca>, "Jim Nasby" <decibel(at)decibel(dot)org>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-12-01 13:27:12
Message-ID: 091a01c7154c$698f5f50$0201a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> How might I determine this?

netstat -a -n

this will list you all current listened ports
you could also try and

telnet localhost 5432

to see if something is listening.

> Would this make a difference when the system is rebooted vs manually
> restarting the server?

when another program is occupying the port, it would probabyl not make much
difference, except if the pgsql service is started before the other tool.

maybe pgsql is already running? ;-)

cheers,
thomas


From: George Weaver <gweaver(at)shaw(dot)ca>
To: "Thomas H(dot)" <me(at)alternize(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-12-01 14:51:32
Message-ID: 004c01c71558$3216aa40$6400a8c0@Dell4500
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Thomas

> netstat -a -n

Cool!

And -o gives me the pid of the process which I can match with processes
through the Task Manager...

> when another program is occupying the port, it would probabyl not make
> much difference, except if the pgsql service is started before the other
> tool.
>
> maybe pgsql is already running? ;-)

The problem I'm having is that if the server (Windows 2000) is rebooted, the
PostgreSQL service starts as expected, but won't accept connections. Bur if
the PostgreSQL service is then restarted manually (via Administrative Tools
> Component Services > Restart), the service runs as expected and everything
is normal.

If I understand what you're suggesting, perhaps upon reboot PostgreSQL is
starting before another app that listens on the same port, which could cause
the problem, but if I then restart the PostgreSQL service this solves the
problem?

Regards,
George


From: "Thomas H(dot)" <me(at)alternize(dot)com>
To: "George Weaver" <gweaver(at)shaw(dot)ca>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-12-01 15:10:39
Message-ID: 099c01c7155a$dcfda9c0$0201a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> If I understand what you're suggesting, perhaps upon reboot PostgreSQL is
> starting before another app that listens on the same port, which could
> cause the problem, but if I then restart the PostgreSQL service this
> solves the problem?

if you can start it manually, then its probably not a problem with another
tool using the same port.

a) do you have a software firewall installed on that machine that might be
interfering here?

b) is your windows in a domain?
if so, make sure you manually set "log on as a service" priviledges on the
domain controller for the local postgres user. the installed only sets local
priviledges that are overwritten upon reboot.

you find the setting here: start -> run -> mmc -> file -> add snapin ->
add -> group policy editor -> browse -> default domain policy
then browse for computer configuration -> windows settings -> security
settings -> local policies -> user rights -> log on as a service. add the
user there.

regards,
- thomas


From: George Weaver <gweaver(at)shaw(dot)ca>
To: "Thomas H(dot)" <me(at)alternize(dot)com>, Jim Nasby <decibel(at)decibel(dot)org>, Harald Armin Massa <haraldarminmassa(at)gmail(dot)com>, Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL doesn't accept connections when Windows
Date: 2006-12-15 15:33:38
Message-ID: 008601c7205e$6549f9b0$6400a8c0@Dell4500
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

----- Original Message From: "Thomas H.", etc.

Thank you all for your replies and suggestions. I apologize for not
replying earlier but the client is located several hours away and I have not
been back to the site until yesterday.

Here's an update of the situation (PostgreSQL 8.1.5 on Windows 2000 Server
system).

The server is not in a domain, but I followed Thomas' suggestion just the
same (>"make sure you manually set "log on as a service" priviledges on the
domain controller for the local postgres user").

Upon reboot of the Windows 2000 server:

1. PostgeSQL service starts without problem.
2. Server is listening on port 5435 as per postgresql.conf file
(verified by netstat).
3. No other application using port 5435.
3. (PostgreSQL 7.3 version listening on port 5432 - no problems)
4. Attempts to connect to PostgreSQL 8.1 result in the following
error message:

C:\Program Files\PostgreSQL\8.1\bin>psql -h name.local -p 5435
feb01-06-01
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

5. There are no related entries in pg_log
6. The following error is in the Windows Event log:

Event Type: Error
Event Source: PostgreSQL
Event Category: None
Event ID: 0
Date: 14/12/2006
Time: 1:06:13 PM
User: N/A
Computer: SERVER
Description:
FATAL: could not reattach to shared memory (key=5435001,
addr=01590000): Invalid argument

7. If PostgreSQL Service is restarted via Control Panel >
Administrative Tools > Component Services, everything runs normally and
there are no problems connecting.

Any further thoughts?

Thanks in advance,
George