could not connect to database postgres - postgresql

createuser: could not connect to database postgres: 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.5432"?
I am trying to install dspace 6.3 on ubuntu server 18.04 but after installing postgresql when I run the command createuser -U postgres -d -A -P dspace I am getting the above error help please

Did you start the server? Try sudo service postgresql restart or sudo systemctl restart postgresql

Related

createuser: could not connect to database postgres: could not connect to server: No such file or directory

I installed postgresql on archlinux using this command:
sudo pacman -S postgresql
And it installed OK. But when I want to create a new user, like this:
sudo -iu postgres
[postgres#amirashabani ~]$ createuser amirashabani
I receive this error:
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"?
How can I fix this?
The problem was that I forgot to start and enable the postgresql service, which was mentioned in the ArchWiki:
Finally, start and enable the postgresql.service.
After doing this:
systemctl start postgresql.service
systemctl enable postgresql.service
Everything worked fine.

Error while connecting to remote Postgres on centos

When I'm trying to connect to Postgres on remote cloud . It is showing :
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Local system -- Postgres 9.3 (windows)
Remote System is on Azure -- Postgres 9.2(centos)
Command I'm using: psql -h "abc.cloudapp.net" -p 5432
I've set the end-point as 5432 in azure
changed the postgresql.conf to "*" to allow connection
and changed the pg_hba to (host all all ip/24 md5)
Please help me out on this.
Endpoint is OK, and you need to set up the network security group as well.
Try to define not just 5432, but the range of ports (1024-65536 for example).
UPD: I was able to create the CentOs 7.0 + PostgreSQL and connected to that instance:
sudo yum install postgresql-server postgresql-contribs
sudo postgresql-setup initdb
sudo vi /var/lib/pgsql/data/pg_hba.conf
Edit 127.0.0.1/32 to 0.0.0.0/0
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo vim /var/lib/pgsql/data/postgresql.conf
sudo service postgresql restart
sudo service postgresql restart
sudo -u postgres createuser --superuser azureuser -P
Then i downloaded pgAdmin and connected to that. (see screenshot) (do not pay attention to the test1 database, just change it to postgres).

postgresql: no such file or directory

I'm trying to install a postgresql database on my VPS server by using this guide.
In there it says
sudo apt-get install postgresql postgresql-contrib libpq-dev
And then
sudo su - postgres
createuser --pwprompt
exit
When I run createuser --pwprompt it asks me to create a password, once I fill it in I get the following error:
createuser: could not connect to database postgres: 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.5432"?
If I do psql --version I get psql (PostgreSQL) 9.4beta3
And which psql outputs /usr/bin/psql
Any idea on how to fix this problem?
Update
Running pg_ctl gives another error
WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'
The program 'pg_ctl' is currently not installed. To run 'pg_ctl' please ask your administrator to install the package 'postgres-xc'
Althgough reading up on postgres-xc shows quite a lot of other problems.

Postgresql starting failed

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

psql: could not connect to server [ubuntu]

Under the postgres user, I tried the psql command and I'm getting this error:
psql: 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.5432"
But when I run /usr/local/pgsql/bin/psql, it is working.
Is there anything wrong with my configuration?
the above issue seems related to PostgreSQL default port no,
Change the port no in postgresql.conf file and restart the DB server. if u have changed the port while installing.
(OR)
instead of psql type full command like
"psql -p 5432 -h localhost"
You could include the database user too:
psql -U postgres -p 5432 -h localhost
Did you reinstall the postgresql-9.6.3 ?
You need to uninstall postgresql completely
sudo apt-get --purge autoremove postgresql*
sudo apt install postgresql-9.6