Linux – Can’t start postgresql service

debianlinuxpostgresqlservice

I'm trying to start the service but it isn't starting… It says:

[….] Starting PostgreSQL 9.6 database server: main[….] The PostgreSQL server failed to start. Please check the log output: 2016-10-25 15:24:26 BDT [4118-1] LOG: could not create IPv6 socket: Permission denied 2016-10-25 15:24:26 BDT [4118-2] LOG: could not create IPv4 socket: Permission denied 2016-10-25 15:24:26 BDT [4118-3] WARNING: could not create listen socket for "localhost" 2016-10-25 15:24:26 BDT [4118-4] FATAL: could not create any TCP/IP sockets 2016-10-25 15:24:26 BDT [4118-5] LOG: da[FAILe system is shut down … failed! failed!

The log file:

2016-10-25 15:25:41 BDT [4330-1] LOG:  could not create IPv6 socket: Permission denied
2016-10-25 15:25:41 BDT [4330-2] LOG:  could not create IPv4 socket: Permission denied
2016-10-25 15:25:41 BDT [4330-3] WARNING:  could not create listen socket for "localhost"
2016-10-25 15:25:41 BDT [4330-4] FATAL:  could not create any TCP/IP sockets
2016-10-25 15:25:41 BDT [4330-5] LOG:  database system is shut down

What should I do?

Best Answer

The permission denied message means one of the two things - Either the user account you are using does not have permission to run the requested program, if you are logged in as root then remember to use sudo.

The second this that is can mean is that the port or resource is currently being used by another program.

In the logfile we see that the daemon cannot open the the port the software is trying to use:

2016-10-25 15:25:41 BDT [4330-1] LOG:  could not create IPv6 socket: Permission denied
2016-10-25 15:25:41 BDT [4330-2] LOG:  could not create IPv4 socket: Permission denied
2016-10-25 15:25:41 BDT [4330-3] WARNING:  could not create listen socket for "localhost"
2016-10-25 15:25:41 BDT [4330-4] FATAL:  could not create any TCP/IP sockets
2016-10-25 15:25:41 BDT [4330-5] LOG:  database system is shut down

This suggests that it is being used by another process.

As mentioned in the comments, try using:

sudo netstat -tulpn

and

sudo lsof -i

to see if there are any other services attempting to use the same port on the machine. If necessary, change the port used by PosgreSQL and this issue should resolve itself.