3

When I execute command:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

I get this error:

pg_ctl: another server might be running; trying to start server anyway
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output

My postgres started:

brew services start postgresql

1
  • 2
    So what's in the server log? Commented Oct 27, 2020 at 13:25

5 Answers 5

7

You should proceed like this:

  1. Look at /usr/local/var/postgres/postmaster.pid. In the first line, you will find a process ID.

  2. Look if there is a process running with the process ID found in the first step.

    • If yes, check if it is a PostgreSQL process.

      • If yes, then your server is already running.

      • if not, remove postmaster.pid (but never, ever remove that file if the process ID belongs to a PostgreSQL process). Then start PostgreSQL like indicated in the next step.

    • If not, start PostgreSQL again like you did, but add -t 1000 to pg_ctl, so that it waits 1000 seconds for PostgreSQL to start up.

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

Comments

2

In windows, look for postgres processes running in background.

To kill with command line, taskkill /f /IM postgres*

1 Comment

I don't think the questioner was asking about a Windows system.
0

I am faced like this problem, when i ran CMD as administrator, the command worked

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

The error clearly highlights that there is already a postgreSQL server. So, first kill the existing server to free up that port using

Note: Change port number if your server is running on a port different than the default one

lsof -i tcp:5432    

This will return any existing processes running on that port and return their PID. Copy the PID and run the following to kill the process.

sudo kill PID
  • Replace PID with your process's PID.

Comments

0

I had a different problem - so documenting it in case it helps someone. Another process (Chrome) had the same PID which was previously assigned to Posgres.

While following @Laurenz Albe's answer (which helped me figure this out), this is what happened:

  1. I ran cat /Users/<my-user>/Library/Application Support/Postgres/var-9.6/postmaster.pid (that's where the file was on my Mac)

  2. First line gave a process ID. I searched for it: ps -ef | grep <id-from-first-line-above>

  3. Chrome was running on that ID :)

  4. I quit Chrome (manually)

  5. Postgres started up fine (I am using the Postgres app)

Comments

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.