0

I am running the latest version of macOS Sierra and I installed PostgreSQL via brew. Then I ran the command:

pg_ctl -D /Users/tmo/PSQL-data -l logfile start

but received for output:

waiting for server to start..../bin/sh: logfile: Permission denied
 stopped waiting
pg_ctl: could not start server
Examine the log output.

EDIT: After restarting my operating system and rerunning the command... I'm now receiving a slightly modified output... but the modification is significant.

waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
  1. Where is the "log output" stored?
  2. How do I make this command work?

1 Answer 1

1

The problem could be one of two things, that I can see:

  1. A typo in your database path:

    • /Users/tmo/PSQL-data --> /Users/tmp/PSQL-data
  2. If the above was just a transcription error, I would guess that your postgres user doesn't have write access to the directory where you are setting the logfile. The argument following the -l switch tells PG where to save the logfile. When you don't provide the -l switch with a path, but just a filename, it will use the same dir you use to specify the database cluster (with the -D flag). So in this case, PG is trying to write to /Users/tmp/PSQL-data/logfile, and getting a permission error.

To fix this, I would try:

  • If the directory /Users/tmp/PSQL-data/ doesn't exist:

    sudo mkdir /Users/tmp/PSQL-data
    
  • Then create the logfile manually:

    sudo touch /Users/tmp/PSQL-data/logfile
    
  • Then make the postgres user own the file (I'm assuming user is postgres here)

    sudo chown postgres /Users/tmp/PSQL-data/logfile
    

Try again, and hopefully you can launch the server.

Caveat: I'm not a macOS user, so I'm not sure how the /tmp folder behaves. If it is periodically cleared, you may want to specify a different logfile location, so that you don't need to create and chown the file each time you need to launch the cluster.

Sign up to request clarification or add additional context in comments.

1 Comment

"When you don't provide the -l switch with a path, but just a filename, it will use the same dir you use to specify the database cluster (with the -D flag)." In my experience it uses the current directory instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.