I'm running macOS Monterey version 12.2.
After restarting my laptop I can no longer connect to my postgresql server. and am getting this error:
(base) user#user Application Support % brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
(base) user#user Application Support % psql postgres
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
I found may suggestions online such as here to remove postmaster.pid. I could not find postmaster.pid in the suggested path (/usr/local/var/postgres/postmaster.pid) however I did find a postmaster.pidunder /usr/local/var/postgres.backup/postmaster.pid which I then removed. but I am still getting the same error.
Can anyone help me with this? And can anyone help clarify why I had no /usr/local/var/postgres/postmaster.pid but did have a /usr/local/var/postgres.backup/postmaster.pid?
I had the same problem today. Postgres stopped working after restarting my computer. If you use brew, you can try brew services restart postgresql but that did not work either.
These commands work for me:
pg_ctl -D /usr/local/var/postgres stop
Then start
pg_ctl -D /usr/local/var/postgres start
You can also check status with pg_ctl -D /usr/local/var/postgres status
Related
NOTE: I have a MacOS Monterey M1 chip.
After I put in the command line - psql postgres - I get the response state below.
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: Connection refused
Is the server running locally and accepting connections on that socket?
I have done the following already:
Restarting PostgreSQL using homebrew brew services restart postgresql
Re-installing PostgreSQL using Homebrew
brew uninstall postgresql
Updating PostgreSQL using Homebrew
brew install postgresql#14
brew services start postgresql#14
brew link postgresql#14 --force
I've just got a new Macbook, and installed it from a backup of my old one.
Now, Homebrew thinks that Postgres is running:
% brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
But I can't connect to any of my databases:
% psql
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
And postgres isn't showing up in the list of running processes:
% ps -ef | grep postgres
501 88781 87701 0 5:34pm ttys000 0:00.00 grep postgres
What should I do? I've looked for postmaster.pid in /usr/local/var/postgres/ - it isn't there.
If the brew service started up, but postgres failed to start within that service, you'll probably need to check the postgres log to see exactly what's wrong. For homebrew, that log is typically located at /usr/local/var/log/postgres.log.
Just a wild guess, but did you also upgrade postgres after the restore from backup? If so, you may need to run
brew postgresql-upgrade-database
to upgrade your data directory (see Postgres - FATAL: database files are incompatible with server). Note that you'll need plenty of free disk space for that command to succeed or it may fail with unintuitive errors.
You should be able to manually start up postgres by just running
postgres
or
postgres &
but you'll need to do that ever time you restart your computer.
If that command fails, you should have the reason why right there in your terminal without having to hunt for logs.
I found some other Stack Overflow threads on this, but, after trying a lot of solutions, couldn't fix the problem.
Upon running the command psql -U postgres, I got the following error message.
psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"
Running the command pg_lsclusters gave me this output:
12 main 5433 down <unknown> /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
Any thoughts?
If everything has been correctly installed and setup the following command should work:
sudo pg_ctlcluster 12 main start
I'm trying to connect to Azure Postgresql using psql from my local machine and get the following error:
$ psql "host=username.postgres.database.azure.com port=5432 dbname=postgres user=username#domain password=mypassword sslmode=require"
psql: error: could not connect to server: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Local Postgres version: 12.1, Azure Postgres database version: 10, macOS Majove.
This issue only recently started after I reinstalled Postgres using Homebrew. I have no issues running $ psql --host=localhost.
I've tried installing postgresql#10 with homebrew so that when I run psql I get the message psql (12.1, server 10.11). But when I attempt to log into Azure Postgres I get the same error as above.
I'm fairly new to Postgres and Azure and would appreciate any suggestions.
Update:
Thanks for the comments and feedback.
I properly installed Postgres 10 with Homebrew and linked it to fix the problem.
$ brew services stop postgresql
$ brew install postgresql#10
$ brew services start postgresql#10
$ brew link --overwrite --force postgresql#10
I can now access the Azure database as expected.
In this case, you could install the PostgreSQL Client for macOS with Homebrew properly then link it as it will symlink all the tools into the /usr/local/bin directory.
To fix this issue, run the following commands:
$ brew services stop postgresql
$ brew install postgresql#10
$ brew services start postgresql#10
$ brew link --overwrite --force postgresql#10
Ref: https://www.compose.com/articles/postgresql-tips-installing-the-postgresql-client/
I was connected with remote postgres-9.3 by pgAdmin III. After close pgAdmin i try to connect on another day with the same db.
/etc/init.d/postgresql-9.3 status
dead but pid file exists
service postgresql-9.3 start FAIL
In pgstartup.log file i have:
This account is currently not available
pg_hba.conf:
# "local" is for Unix domain socket connections only
local all all peer
host all all 127.0.0.1/32 trust
host all all 89.70.224.82/32 md5
Operating system on server is CentOS. I don't know unfortunately how postgres was installed on the server because someone else done that.
What i can do with this?
The solution is reset your PostgreSQL logs
[root#user /]#/usr/pgsql-9.3/bin/pg_resetxlog -f /usr/pgsql-9.3/data/
after executing above command display "Transaction log reset"
and then restart PostgreSQL server
[root#user /]# /etc/init.d/postgresql-9.3 restart
Stopping postgresql-9.3 service: [FAILED]
Starting postgresql-9.3 service: [ OK ]
[root#qa /]# /etc/init.d/postgresql-9.3 status
(pid 3003) is running...
after checking your pgadmin
Try to start cluster using native postgres utility.
Assuming you have CentOS 6.6 and postgresql 9.4
sudo -u postgres /usr/pgsql-9.4/bin/pg_ctl -D <YOUR_DATA_DIR> start
You will get some reasonable output.
Then try to start postgres in single user mode
sudo -u postgres /usr/pgsql-9.4/bin/postgres --single -D <YOUR_DATA_DIR> -P -d 1
Beware that resetting xlogs will cause some data lost.
I also recommend to read this article http://blog.endpoint.com/2014/11/when-postgres-will-not-start.html