connection to server on socket failed postgres ubuntu - ruby-on-rails

I'm trying to run postgres on ubuntu and it shows the following error
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
I have made research all through the internet yet to no avail. Any help would be highly appreciated

Related

Postgresql version 13 psql: error: could not connect to server: could not connect to server: No such file or directory

I'm currently working with a Rails 6 application and Postgresql. I been having issues when I run rails db:create. This error seem to happen after I updated brew upgrade I get the following error:
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
I'm running Mac OS Mojave and I updated postgresq to version 13.
$ postgres --version
postgres (PostgreSQL) 13.0
I'm guessing this is why I have issues, I noticed in some of the other posts that running brew postgresql-upgrade-database might be a FIX to this problem, however when I run the command I get:
$ brew postgresql-upgrade-database
Error: No such file or directory # rb_sysopen - /usr/local/var/postgres/PG_VERSION
But I can see the .old file when I navigate to postgres as shown in the image below:
Also, if I tried connecting to psql I get an error
$ psql
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 "/tmp/.s.PGSQL.5432"?
I also see that the service is running:
$ ps -ef | grep postgres
501 48733 5971 0 1:23PM ttys011 0:00.31 /usr/local/Cellar/macvim/8.2-166_1/MacVim.app/Contents/MacOS/Vim /usr/local/var/postgres/
501 52975 5971 0 1:54PM ttys011 0:00.01 grep postgres
What can the issue be?
this fixed it for me
initdb `brew --prefix`/var/postgres/data -E utf8
and then running
pg_ctl -D /usr/local/var/postgres/data -l logfile start
Follow PostgreSQL with Homebrew on Mac for more detail

Unable to start postgresql server [could not bind IPv4 socket: Permission denied]

I am trying to start my PostgreSQL 9.4 database server on my local Windows machine via Ubuntu console. I'm running the command sudo service postgresql start, but I'm receiving the following error output:
The PostgreSQL server failed to start. Please check the log output:
2020-02-25 09:57:30.216 CST [497] LOG: could not bind IPv4 socket: Permission denied
2020-02-25 09:57:30.216 CST [497] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2020-02-25 09:57:30.217 CST [497] WARNING: could not create listen socket for "localhost"
2020-02-25 09:57:30.217 CST [497] FATAL: could not create any TCP/IP sockets [fail]
How do I check if another postmaster is already running on port 5432? If there is one, how would I stop it? Thank you!

could not connect to server: Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

this is the massage I'm getting when I try to run the localhost I don't know what's the problem:
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"?
I have uninstall postgresql and reinstall it again but the problem persist

Connection failed: Host 'linux547.grserver.gr' is not allowed to connect to this MariaDB server

code here i am trying to connect my site to a database using this code:
but I get this error:
Connection failed: Host 'linux547.grserver.gr' is not allowed to connect to this MariaDB server
Does anyone have any suggestions? Thanks

pg_dump: [archiver (db)] connection to database "development" failed: could not connect to server: Connection refused

In trying to push my database from my development.sqlite3 file to my Heroku app, I encountered the following error message:
pg_dump: [archiver (db)] connection to database "development" failed: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
pg_restore: [archiver] input file is too short (read 0, expected 5)
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
I am new to Heroku and can't figure this one out. Hoping it's something simple I'm overlooking.
First off, sqlite isn't intended to be used in production. In fact, Heroku doesn't support using sqlite, so you'll need to switch to Postgres if you want to use your app with Heroku: https://devcenter.heroku.com/articles/getting-started-with-rails4#write-your-app.
The specific error you're getting is because your heroku app is to connect to port 5432, which is utilized by Postgres by default and is not used by sqlite. However, since you don't have a PG server to connect to on localhost, you app is failing with that error.

Resources