Postgresql not starting even after editing rc file - postgresql

I receive the following error when I try to start postgresql aka psql in Slackware Linux:
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 am trying to start it and changed the field in pg_hba.conf to trust from md5.
At some point it was asking for a password.
I get the following when I try to start the server:
bash-5.1# postgres -D /pgsql/data
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
bash-5.1# postgres -D /pgsql/data >logfile 2>&1 &
[1] 8310

Related

How to use postgresql in nixos

I've installed posgresql:
nix-env -iA nixos.postgresql
Now I wanto use it.
psql
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Must I add something in /etc/nixos/configuration.nix ?
update
I've tried to do like this link. i.e. install in nix-shell and not in nix-env.
I've the same shell.nix
nix-shell --pure shell.nix
done
server started
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 "/mnt/c/Users/Pierre-Olivier/nix/psql/.pg/.s.PGSQL.5432"?
psql is the PostgreSQL interactive terminal.
What you are trying to do is connect to database without PostgreSQL running in first place.
Follow these steps:
Initialize the database with initdb -D .data
Start a PostgreSQL server with pg_ctl -D .data -l logfile start
Make sure it's running pg_ctl -D .data status
Connect to database with psql -d postgres (by default, postgres database is created)
At the end, make sure to stop database with pg_ctl -D .data stop when leaving the nix shell.

GPDB-psql: could not connect to server: No such file or directory

We have the small array of Greenplum database.In that, We have a master node. when I am trying to use PSQL utility
Getting this error :
[gpadmin#master gpseg-1]$ psql
PSQL: 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"?
We tried
on searching for postmaster.pid files.We have removed it.But still, the error remains.
You need to export your PGPORT and source Postgres.sh_path(inside your GPDB).
After that you will be able to do psql and connect to the database.

Trouble installing Gitlab on CentOS 6.5

I have attempted, several times to install Gitlab on my CentOS 6.5 VPS as per the instructions on the Official page and every time, it fails during the "gitlab-ctl reconfigure" stage of installation. I tried googling around and looking in other questions on here without much luck.
Error is as follows:
* execute[create gitlab database user] action run
================================================================================
Error executing action `run` on resource 'execute[create gitlab database user]'
================================================================================
---- Begin output of /opt/gitlab/embedded/bin/psql --port 5432 -d template1 -c "CREATE USER gitlab" ----
STDOUT:
STDERR: psql: 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"?
---- End output of /opt/gitlab/embedded/bin/psql --port 5432 -d template1 -c "CREATE USER gitlab" ----
This might not be immediately related to GitLab, but to PostgreSQL itself.
See "Chapter 17. Server Setup and Operation", section "Client Connection Problems":
Alternatively, you'll get this when attempting Unix-domain socket communication to a local server:
psql: 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"?
The last line is useful in verifying that the client is trying to connect to the right place.
If there is in fact no server running there, the kernel error message will typically be either Connection refused or No such file or directory, as illustrated.
(It is important to realize that Connection refused in this context does not mean that the server got your connection request and rejected it. That case will produce a different message, as shown in Section 19.4.)
Other error messages such as Connection timed out might indicate more fundamental problems, like lack of network connectivity.
So make sure the database can start first.
The OP Luke Usher confirms in the comments:
The default PostgreSQL config included in gitlab was set to allocate more memory for shared_buffer than I have available.
This was corrected by adding postgresql['shared_buffers'] = "1024MB" to /etc/gitlab/gitlab.rb.

How do I get a Postgres server to createdb and shut down?

I have an instance of a Postgres server running that I've started with the command:
pg_ctl -D /usr/local/var/postgres/data -l /usr/local/var/postgres/data/server.log start
Running the command createdb test prompts me for my password twice, then I get this error:
createdb: could not connect to database template1: FATAL: password authentication failed for user "joey"
Also, when I try to stop the server using
pg_ctl -D /usr/local/var/postgres/data stop -m smart
I get this error message:
pg_ctl: PID file "/usr/local/var/postgres/data/postmaster.pid" does not exist
Is server running?
Is there something I'm missing or forgot to initialize/install? I used these instructions to install.
I checked this answer and this answer and neither of the two fixed my problem.
From the log file you added in your comment, it looks as if either there is another postgresql instance running on the machine (or possibly something else which is using the same port as postgresql wants to use):
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
This is stopping the database from starting up to begin with.
To see what process that could be, you can use lsof:
$ sudo lsof | grep -i listen
...
postmaste 19732 postgres 3u IPv6 1194355 0t0 TCP localhost:postgres (LISTEN)
postmaste 19732 postgres 4u IPv4 1194356 0t0 TCP localhost:postgres (LISTEN)
...
In the above sample, from a Linux host, you can see that a process called postmaster (it is truncated in the printout) listens on localhost:postgres, meaning the localhost address port 5432 (lsof is translating the port 5432 into 'postgres' via the file /etc/services which contains a mapping between well known port numbers and corresponding services).
The fact that createdb is prompting for your password implies that it is connecting to a database somewhere, although I could not spot it the ps printout you sent.
The other part of your question was why createdb could not connect to your database (or whatever database is running on your machine). If it is a freshly created database cluster then it will not have any users defined other than the default 'postgres' user. You must issue commands with this user:
createdb -U postgres test
Without the -U option it will try to connect using your current login user, which won't exist in the database.
It might also be that you will need to authenticate as the postgres user. The file pg_hba.conf in the postgresql data directory controls what kind of authentication will be needed.
In general the postgresql documentation is excellent; I suggest you read through the section Server Setup and Operation to check that you have a valid configuration.

Postgres Database Local Installation / Running

Trying to setup Postgres / PostGIS on OSX Mountain Lion to use with Django. However, something is wrong and I am not sure how to fix it.
$ createdb geo
createdb: 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/pgsql_socket/.s.PGSQL.5432"?
$ postgres -D /usr/local/var/postgres
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 221) running in data directory "/usr/local/var/postgres"?
$ pg_ctl -D /usr/local/var/postgres -l logfile start
pg_ctl: another server might be running; trying to start server anyway
server starting
Then I found this gist that said how to fix it on lion. However it did not work for me:
$ kill -9 221
$ pg_ctl -D /usr/local/var/postgres stop
waiting for server to shut down.... done
server stopped
$ pg_ctl -D /usr/local/var/postgres start
pg_ctl: another server might be running; trying to start server anyway
server starting
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 1436) running in data directory "/usr/local/var/postgres"?
Another attempt:
$ cd /usr/local/var/postgres
$ mv postmaster.pid postmaster.backup
$ pg_ctl -D /usr/local/var/postgres start
server starting
$ LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
Has anyone successfully done this with mountain lion? If so, what am I missing? Thanks for your help with this issue!
This message:
createdb: 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/pgsql_socket/.s.PGSQL.5432"?
indicates that your PostgreSQL server doesn't use /var/pgsql_socket as its Unix domain socket directory, which is the rendez-vous point between the server and the client. This is quite common, since only PostgreSQL shipped by Apple with OSX server uses that path. Incidentally, this is why the createdb command as shipped by Apple tries to connect to the server as configured by Apple.
From that point, there are a lot of different solutions to work around the problem, but the more obvious one would be to use the createdb command that comes with your PostgreSQL installation instead of the one that is preinstalled in your system.
Should you need further help with that, you should specify how you installed PostgreSQL, because there are quite a few different packages that provide it, and they all use different paths to avoid trampling over each other.
Update for Homebrew
If using brew, I suggest to apply the answer on superuser.com:
How should I set the PATH variable on my Mac so the Hombrew-installed tools are found?
Presumably the author of the Postgres+Postgis tutorial you're referring to has changed its PATH long ago and forgot to mention it in his text.
Once done, the command which createdb should return /usr/local/bin/psql which is the homebrew version instead of the initial /usr/bin/psql which is the Apple version.