I am attempting to set up a Windows XP Test Agent running Ruby on Rails against a PostgreSQL Database. I’ve installed PostgreSQL 9.2 for Windows, with default settings. However, when I attempt to start the service from the Service Control Panel, the following error message appears(irrelevantly of which User I attempt to set it to):
The postgres-9.2 -PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services
stop automatically if they have work to do, for example, the Performance Logs and Alerts service.
If I attempt to launch it from the command line (whether cmd.exe or git bash doesn’t matter with):
E:\PostgreSQL\9.2\bin\pg_ctl.exe start -D E:\PostgreSQL\9.2\data
It will claim:
server starting
However it will fail to start (rake db:migrate will report the server as not running, the postgresql process is missing from Task Manager, the Service is listed as down in the Service List, and
E:\PostgreSQL\9.2\bin\pg_ctl.exe stop -D E:\PostgreSQL\9.2\data
Will report
pg_ctl: PID file "E:/PostgreSQL/9.2/data/postmaster.pid" does not exist Is server running?
While attempting to start it as a server through pg_ctl:
E:\PostgreSQL\9.2\bin\pg_ctl.exe runservice -D E:\PostgreSQL\9.2\data
Fails with:
pg_ctl: could not start service PostgreSQL: error code 1063
EDIT:
the contents of pg_hba:
# TYPE DATABASE USER ADDRESS METHOD
local all all all trust
# IPv4 local connections:
host all all all trust
host all all 127.0.0.1/32 trust
# IPv6 local connections:
#host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication all all trust
#host replication postgres 127.0.0.1/32 trust
#host replication postgres ::1/128 trust
Checking in pg_log as per comments below:
2012-10-28 22:47:44 PDT LOG: local connections are not supported by this build
2012-10-28 22:47:44 PDT CONTEXT: line 78 of configuration file "E:/PostgreSQL/9.2/data/pg_hba.conf"
2012-10-28 22:47:44 PDT FATAL: could not load pg_hba.conf
Line 78 is
local all all all trust
The same error still occurs when running as a service (whether through pg_ctl runservice or from the services control panel). However pg_ctl start now starts postgres without incident.
I’ll go with “good enough”
PS: The Event Log entries merely say “Timed out waiting for server startup”
UPDATE After edits to question:
Delete the lines from
pg_hba.confthat begin withlocal. They relate to UNIX socket connections, which PostgreSQL does not support. Then, unless something else is also wrong, you should be able to start PostgreSQL. Most likely you copied and pasted apg_hba.conffrom a site that talks about PostgreSQL on Mac OS X or Linux, wherelocalconnections are supported.If Pg still fails to start after fixing
pg_hba.conf, check the logs again and see what else it’s complaining about.By the way, in general I don’t recommend trying to run PostgreSQL both as a service and via
pg_ctlfrom the same data directory. You’re likely to land up with file systems permissions problems that are difficult and annoying to resolve, especially on Windows.In addition to @mvp’s suggestions, it’s possible that you are trying to start PostgreSQL under a user that is a member of the Administrators group. This is not permitted and will fail. I disagree with that policy, but that’s how it is at the moment.
By default 9.2 is set up to run under the NetworkService, so that should not be a problem. If you configured it to run under a different user account this could be your problem, and it could be the problem when running it manually too.
It’s more likely that when starting it manually you just don’t have file system permissions to the data directory.
BTW, if
E:\is FAT32, there’s your problem. FAT32 is not supported. You must use NTFS.Rather than stab in the dark, you should really be looking at the server logs in
E:\PostgreSQL\9.2\data\pg_logand the event viewer to see what’s causing it to fail to start.