1

I am trying to get Postgres 9.2.4 to run as a service on Windows 7. After installing postgres, the service was running fine. However, after setting postgres up as a server for another program, the service stopped running. When I try to start the service now, I get a message saying :

"The postgresql-x64-9.2 - PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs."

When I try running the program that should use the database server, I get this error :

"A problem was encountered while attempting to log into or create the production database. Details: Could not connect to the server; Could not connect to remote socket. The application must now close"

I have also encountered this error once while opening the same program :

"A problem was encountered while attempting to log into or create the production database. Details: FATAL: could not load pg_hba.conf The application must now close."

I have tried running the service logged on as a local system account as well as my own account (In the postgres service properties) to no avail. I also tried restarting my computer. After a lot of troubleshooting online, I learned that a good thing to check is the pg_log file. Here are the contents of the latest pg_log entry :

2013-05-29 14:59:45 MDT LOG:  database system was interrupted; last known up at 2013-05-29 14:58:01 MDT
2013-05-29 14:59:45 MDT LOG:  database system was not properly shut down; automatic recovery in progress
2013-05-29 14:59:45 MDT LOG:  record with zero length at 0/175BB98
2013-05-29 14:59:45 MDT LOG:  redo is not required
2013-05-29 14:59:45 MDT LOG:  database system is ready to accept connections
2013-05-29 14:59:45 MDT LOG:  autovacuum launcher started
2013-05-29 15:07:00 MDT LOG:  local connections are not supported by this build
2013-05-29 15:07:00 MDT CONTEXT:  line 1 of configuration file "C:/PostgreSQL/data/pg_hba.conf"
2013-05-29 15:07:00 MDT FATAL:  could not load pg_hba.conf
2013-05-29 15:07:00 MDT LOG:  local connections are not supported by this build
2013-05-29 15:07:00 MDT CONTEXT:  line 1 of configuration file "C:/PostgreSQL/data/pg_hba.conf"
2013-05-29 15:07:00 MDT FATAL:  could not load pg_hba.conf
2013-05-29 15:09:03 MDT LOG:  received fast shutdown request
2013-05-29 15:09:03 MDT LOG:  aborting any active transactions
2013-05-29 15:09:03 MDT LOG:  autovacuum launcher shutting down
2013-05-29 15:09:03 MDT LOG:  shutting down
2013-05-29 15:09:03 MDT LOG:  database system is shut down

It seems to be having issues with the pg_hba.conf file, which looks like this :

local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host all all 0.0.0.0 0.0.0.0 trust

As per many suggestions online, I tried editing the top line to a number of different alternatives (host all all trust / host all 127.0.0.1/32 trust / host all 192.168.0.100/24 trust , etc.). This made sense to me, as the log file was saying that local connections are unsupported by postgres and was also pointing to that line. However, none of my changes had any effect. I tried restarting my computer after every change but nothing made any difference.

When I searched for examples of what a pg_hba.conf file normally looks like, the examples looked slightly different from my file. I noticed that in the PostgreSQL program file, in addition to pg_hba.conf, there was also a "20130529-150444-old-pg_hba.conf" file which looked a lot more like the examples I was finding online. This file has several lines of comments before these last few lines :

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

I was hoping that this was the original pg_hba.conf file and that if I replaced the new file with the contents of the old one, postgres would start working again. No such luck. I have been hoping for more error files to be logged in pg_log to see if the previously stated error had disappeared or changed to something else, but no more files have been logged.

I have been troubleshooting online for a few days now and nothing I've found has worked. Sorry for having such a long question, but I wanted to be thorough and include all relevant information. I would appreciate it if anyone could shed some light on this problem or offer suggestions.

1 Answer 1

0
  1. Have you run initdb before?

    If you haven't, that will cause the problem. Once you run the initdb command, you will see a data directory, which should contain a default pg_hba.conf.

  2. Then you need to replace the default pg_hba.conf with your customized pg_hba.conf.

  3. You need to set the $PGDATA. In CentOS, it is located at /etc/sysconfig/pgsql/postgresql.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .