Reputation: 157
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
Upvotes: 3
Views: 39998
Reputation: 248030
You should proceed like this:
Look at /usr/local/var/postgres/postmaster.pid
.
In the first line, you will find a process ID.
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.
Upvotes: 7
Reputation: 15620
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:
I ran
cat /Users/<my-user>/Library/Application Support/Postgres/var-9.6/postmaster.pid
(that's where the file was on my Mac)
First line gave a process ID. I searched for it:
ps -ef | grep <id-from-first-line-above>
Chrome was running on that ID :)
I quit Chrome (manually)
Postgres started up fine (I am using the Postgres app)
Upvotes: 0
Reputation: 361
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
Upvotes: 0
Reputation: 1
I am faced like this problem, when i ran CMD as administrator, the command worked
Upvotes: 0
Reputation: 23
In windows, look for postgres processes running in background.
To kill with command line, taskkill /f /IM postgres*
Upvotes: 2