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.
Client authentication is controlled by a configuration file, which traditionally is named pg_hba. conf and is stored in the database cluster's data directory. ( HBA stands for host-based authentication.)
conf, pg_hba. conf, etc.). This allows changing of configuration-file options that do not require a complete restart to take effect. status mode checks whether a server is running in the specified data directory.
Open the postgresql. conf configuration file. This file is located at %postgresql_dir%\data . Here %postgresql_dir% (for example, C:\Program Files\PostgreSQL\11 ) is the folder that PostgreSQL was installed in.
By default, the file is named pg_hba. conf. By default, on RHEL 7 , the file is at /var/lib/pgsql/data/, and on Windows, the file is at C:\Program Files\PostgreSQL\ version_number \data\. Note: You must not change your local authentication method.
The local entry is not supported on Windows machines. See E.20.3.1.3. Authentication.
Reject local lines in pg_hba.conf on platforms that don't support Unix-socket connections (Magnus Hagander)
Formerly, such lines were silently ignored, which could be surprising. This makes the behavior more like other unsupported cases.
Change your configuration from:
local all all trust
to:
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
For more info, consult 19.1. The pg_hba.conf File.
I had this problem with Postgresql version 8.3 after installing it on a Windows 7 machine. Initially it was working normally, but suddenly it stopped (probably after some Windows update). Many tentatives were made changing permissions, but it didn't put it to work. Some months later I found the problem in a file which was empty, meanwhile it should have some data. Verify this path: C:\Program Files (x86)\Postgresql\8.3\data\ (where 8.3 must be replaced to your version number). Check if the file Postmaster.pid is empty or not (open it using Wordpad or Notepad). If it is empty, rename it to _Postmaster.pid (or other name). Go to Start menu and at the command box type services.msc Press Enter Locate the Postgresql Database entry Double click on it Click on Start button If the service starts, a new Postmaster.pid will be created (with some data) You can check it in the path indicated above.
The good tip came from analysing the Event Viewer: Open Windows Explorer, select "Computer", right click on "Manage", select "Event Viewer", wait "Summary of Administrative Events" to load, open the "Error" node, locate "PostgreSQL" entry in the "Source" column and doubleclick on it. There was the tip informing bogus data in the Postmaster.pid file.
I hope this information can help you. Cheers! Ed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With