My postgres was working previously, but for some reason does not work anymore. I have tried several different searches in stack overflow and other sites, and after coming up with the same results and reading the same pages over and over again, without any success, it was time to post a new question.
Trying to run my rails project on the local host raises the following error message:
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"?
The server is not running at all, as indicated by the following output from
ps -fu postgres:
postgres 23969 23968 0 09:54 pts/25 00:00:00 -bash
Error messages that I'm getting:
- When running as the "postgres" user, executing
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"?
- When trying to start postgres:
Other things I have tried:
postgres -D /usr/local/pgsql/data >logfile 2>&1 &(as indicated by the official documentation) outputs:
 24670. But the server still doesn't run.
I also tried starting the server via
service postgres start. This prompts me to my password to authenticate me as the user (it says
Authentication is required to start 'postgres.service'.) My login succeeds (
==== AUTHENTICATION COMPLETE ===)but then it says
Failed to start postgres.service: Unit postgres.service not found.
I tried restarting the server (following these instructions using
sudo /etc/init.d/postgresql restart), which in the past did fix postgres, but now simply prompts
Restarting postgresql (via systemctl): postgresql.service.However, now I try to start the server again, and nothing has changed.
The problem does not seem to be any postmaster.pid file that I need to remove. After going through the same process that this user did, nothing was found when running
sudo find / -name .s.PGSQL.5432 -ls
- I have tried a clean install, and it still doesn't work. Nothing has changed, and the same error messages are appearing.
After removing postgres (following these instructions), I went through the digital ocean tutorial up to the point where it says "You can now access a Postgres prompt immediately by typing:
Other possible factors: (I am at my wit's end, so I'm listing any possible factor that comes to mind)
- I am running Ubuntu Xenial (16.04), and postgresql 9.5
- I recently moved and am using a new Internet provider. I'm not sure why this would be an issue, but it did require me to change other settings (specifically, to deploy my rails project locally, instead of localhost:3000 I was using my inet addr. In other words, "http://:3000" (where is the number provided for inet by ifconfig). But after moving to a new Internet provider, my inet addr changed.
- [Update] Log files:
LOG: could not bind IPv4 socket: Cannot assign requested address
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
At this point I spent several hours to no avail... Please help!!
netstat -tulpn | grep :5432
(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.). when I run it using sudo, I get
sudo: unable to resolve host <my_machine>
remove-d postgres. In my case the configuration files did not all have owner: "
startwas giving me: "
Loaded: not-found (Reason: No such file or directory)" errors. Why? File owner. Evidently I'd edited a file and not reset the ownership. tsk, tsk tsk