Postgres could not load private key file

I guessed it’s more than a year that I never try to setup an application to connect to the Postgres database. General troubleshooting steps for customers such as incorrect username/password that causes the failure to connect to the database or incorrect location for the jdbc jar file are common tips that you can think of whenever someone comes to you and telling you that he/she has the problem in connecting to the postgres database.

As for hands-on setting up Postgres database, that might be around three years ago, when I was still an intern.

I had followed the guidelines provided from this blog post: http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804. In fact, the post is quite detailed and everything should works fine but what I experienced is out of the guideline scope or I’m too noob in Postgres 😛

Once the installation has completed, I tried to restart the postgres:-

sudo /etc/init.d/postgresql-8.3 restart

But it fails:

* Restarting PostgreSQL 8.3 database server
* The PostgreSQL server failed to start. Please check the log output:

Enter PEM pass phrase:

2010-04-28 16:27:33 MYT FATAL: could not load private key file “server.key”: problems getting password

[fail]

The error seems related to certificate issues or failure to obtained some key files but I never try to implement any security features for the installation. Besides that, I never experienced this before when I setup a Postgres database last time. After a bit of googling with some keywords, it’s seems related to the SSL configuration.

In order to resolve the error, you need to edit the postgresql.conf file(located in my /etc/postgresql/8.3/main directory). By default, the ssl is set to true and that is the reason which causes the “meaningful” error. You need to set it to false:-

ssl = false                             # (change requires restart)

Please note that you might either need to change the owner of the file or switch user to *postgres* in order to edit the file else you do not have the permission to do so.

Once you had edited the file, try to restart the postgres:

sudo /etc/init.d/postgresql-8.3 restart

* Restarting PostgreSQL 8.3 database server [ OK ]

Now, everything back to normal 🙂

3 thoughts on “Postgres could not load private key file

Leave a comment