Postgresql Won't Start: "Server.Key" Has Group or World Access

PostgreSQL won't start: server.key has group or world access

I had solved it using ..

1) Enter the relevant directory (use> locate server.key)

2) Back up old server.key link.

3) Copy ssl-cert-snakeoil.key to server.key

4-5) Change its owner & group to postgres

6) Ensure the permissions are 700 or 740 (as requested by error message)

Recipe for my Ubuntu 12.04 & postgresql-8.3:

sudo cd /var/lib/postgresql/8.3/main/
sudo mv server.key server.key-0
sudo cp /etc/ssl/private/ssl-cert-snakeoil.key server.key
sudo chown postgres server.key
sudo chgrp postgres server.key
sudo chmod 740 server.key
sudo /etc/init.d/postgres-8.3 start

And now its working !
Thanks for support.

PostgreSQL: Why psql can't connect to server?

The error states that the psql utility can't find the socket to connect to your database server. Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed.

Step 1: Verify that the database is running

The command may vary depending on your operating system. But on most *ix systems the following would work, it will search for postgres among all running processes

ps -ef | grep postgres

On my system, mac osx, this spits out

501   408     1   0  2Jul15 ??         0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log

The last column shows the command used to start the server, and the options.

You can look at all the options available to start the postgres server using the following.

man postgres

From there, you'd see that the options -D and -r are respectively the datadir & the logfilename.

Step 2: If the postgres service is running

Use find to search for the location of the socket, which should be somewhere in the /tmp

sudo find /tmp/ -name .s.PGSQL.5432

If postgres is running and accepting socket connections, the above should tell you the location of the socket. On my machine, it turned out to be:

/tmp/.s.PGSQL.5432

Then, try connecting via psql using this file's location explicitly, eg.

psql -h /tmp/ dbname

Step 3: If the service is running but you don't see a socket

If you can't find the socket, but see that the service is running, Verify that the pg_hba.conf file allows local sockets.

Browse to the datadir and you should find the pg_hba.conf file.

By default, near the bottom of the file you should see the following lines:

# "local" is for Unix domain socket connections only
local all all trust

If you don't see it, you can modify the file, and restart the postgres service.

Cannot connect to Postgres server running through brew services

I had the same error and I fixed it by removing the process pid file:

rm -f /usr/local/var/postgres/postmaster.pid

connection to server at localhost , port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?

The problem is that /etc directory needs to be root user, so I changed it to root user, and opened 5432 port, in my case /etc directory owned by other user, now everything is working.

Unable to start postgresql.service?

Finally, I figured this one out. There was already a file present

/usr/lib/systemd/system/postgresql-9.6.service

So, may be due to the presence of this file, I was not able to start postgresql.service. Then I tried to start postgresql-9.6.service as follows:

[code_master5@BitBox ~]$ sudo systemctl start postgresql-9.6.service
Failed to start postgresql-9.6.service: Unit postgresql-9.6.service not found.

And, as you can see the output, again it failed.

I simply deleted the file using sudo as I thought may be postgresql.service file is not being created by relevant program due to the presence of this file. Then I restarted the system. It's working fine since then, as you can see the output below:

[code_master5@BitBox ~]$ sudo systemctl status postgresql.service
[sudo] password for code_master5:
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor p
Active: active (running) since Sat 2017-01-28 09:31:30 IST; 7h ago
Main PID: 342 (postgres)
Tasks: 6 (limit: 4915)
CGroup: /system.slice/postgresql.service
├─342 /usr/bin/postgres -D /var/lib/postgres/data
├─358 postgres: checkpointer process
├─359 postgres: writer process
├─360 postgres: wal writer process
├─361 postgres: autovacuum launcher process
└─362 postgres: stats collector process

Jan 28 09:31:26 BitBox systemd[1]: Starting PostgreSQL database server...
Jan 28 09:31:28 BitBox postgres[340]: FATAL: the database system is starting up
Jan 28 09:31:28 BitBox postgres[340]: LOG: database system was shut down at 201
Jan 28 09:31:29 BitBox postgres[340]: FATAL: the database system is starting up
Jan 28 09:31:29 BitBox postgres[340]: LOG: MultiXact member wraparound protecti
Jan 28 09:31:29 BitBox postgres[340]: LOG: database system is ready to accept c
Jan 28 09:31:29 BitBox postgres[340]: LOG: autovacuum launcher started
Jan 28 09:31:30 BitBox systemd[1]: Started PostgreSQL database server.

I would surely like to warn all those having same problem. Please do whatever I did at your own risk. Since these are system files. Messing with these can spoil your weekend!

I am still a bit confused on this though. Explanations are welcome!

Can't connect to Postgresql on port 5432

You have to edit postgresql.conf file and change line with 'listen_addresses'.

This file you can find in the /etc/postgresql/9.3/main directory.

Default Ubuntu config have allowed only localhost (or 127.0.0.1) interface, which is sufficient for using, when every PostgreSQL client work on the same computer, as PostgreSQL server. If you want connect PostgreSQL server from other computers, you have change this config line in this way:

listen_addresses = '*'

Then you have edit pg_hba.conf file, too. In this file you have set, from which computers you can connect to this server and what method of authentication you can use. Usually you will need similar line:

host    all         all         192.168.1.0/24        md5

Please, read comments in this file...

EDIT:

After the editing postgresql.conf and pg_hba.conf you have to restart postgresql server.

EDIT2: Highlited configuration files.

FATAL: could not access private key file /etc/ssl/private/ssl-cert-snakeoil.key : Permission denied

The error happens because you're trying to launch PostgreSQL as your own unpriviledged user, and it's not meant to run like that.

Ubuntu provides PostgreSQL packaged in a way that it should be launched with:

 $ sudo /etc/init.d/postgresql start
# or
$ sudo service postgresql start

or for finer-grained control with pg_ctlcluster, see
http://manpages.ubuntu.com/manpages/trusty/man8/pg_ctlcluster.8.html



Related Topics



Leave a reply



Submit