PostgreSQL 13 – Not starting

Over the last two years, I’ve had a mix of friends and acquaintances start to look at PostgreSQL.  I’ve initially was like ok, I’ll get to when I can.  Well, I’ve started to dive into this topic a bit more and expanding my knowledge on the topic (for personal and business reasons). If you look at the industry as a whole, a lot of organizations are moving to PostgreSQL for a whole host of reason and this has lead to an expansion of different variants of PostgreSQL.  

For the purpose of this post, I’m only looking at PostgreSQL 13.  After getting PostgreSQL 13 installed (via these instructions), I was having a problem getting PostgreSQL to start.  The error message I was getting when I ran pg_ctl was:

-bash-4.2$ /usr/pgsql-13/bin/pg_ctl -D /var/lib/pgsql/13/data/ -l logfile start
waiting for server to start…. stopped waiting
pg_ctl: could not start server
Examine the log output.

Following what the output suggested, I went and looked at the log file in /var/lib/pgsql/13/data/log.   This output referenced that fact that PostgreSQL couldn’t establish the port (5432) and then shuts down.

2021-08-16 00:29:30.348 UTC [5900] LOG: starting PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2021-08-16 00:29:30.348 UTC [5900] LOG: listening on IPv6 address “::1”, port 5432
2021-08-16 00:29:30.349 UTC [5900] LOG: listening on IPv4 address “127.0.0.1”, port 5432
2021-08-16 00:29:30.350 UTC [5900] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2021-08-16 00:29:30.351 UTC [5900] FATAL: could not create lock file “/tmp/.s.PGSQL.5432.lock”: Permission denied
2021-08-16 00:29:30.353 UTC [5900] LOG: database system is shut down

After some review and tinkering with different things, I figure I would check the permissions on the /tmp directory.  After all that is where PostgreSQL is trying to write the lock file.  

As root user, I modified the /tmp directory to allow full access for everyone.  The following is what I ran:

$ chmod 1777 /tmp

With the permissions updated on /tmp, I attempted to start the PostgreSQL database again with pg_ctl.  The results were that the PostgreSQL database started without an issue.

2021-08-16 00:30:48.306 UTC [5999] LOG: starting PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2021-08-16 00:30:48.306 UTC [5999] LOG: listening on IPv6 address “::1”, port 5432
2021-08-16 00:30:48.306 UTC [5999] LOG: listening on IPv4 address “127.0.0.1”, port 5432
2021-08-16 00:30:48.308 UTC [5999] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
2021-08-16 00:30:48.310 UTC [5999] LOG: listening on Unix socket “/tmp/.s.PGSQL.5432”
2021-08-16 00:30:48.313 UTC [6001] LOG: database system was shut down at 2021-08-16 00:01:18 UTC
2021-08-16 00:30:48.316 UTC [5999] LOG: database system is ready to accept connections

This is just something to keep in mind when start PostgreSQL databases in new environments be it is development or production.

Enjoy!!!

Twitter: @dbasolved/@rheodatallc

Please follow and like:

Enquire now

Give us a call or fill in the form below and we will contact you. We endeavor to answer all inquiries within 24 hours on business days.