Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Sunday, May 29, 2016

psql: could not connect to server: No such file or directory (Mac OS X)

psql: could not connect to server: No such file or directory (Mac OS X)


please note: I'm posting this question in hopes that it will help others with this issue. i've searched a lot here and didn't see an issue/answer which was quite the same so i wanted to post this, and answer it myself in the hopes it will help others...

so, upon restarting my macbook i got the dreaded Postgres 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"?  

the reason this happened is because my macbook froze completely due to an unrelated issue and I had to do a hard reboot using the power button. after rebooting i couldn't start Postgres because of this error.

Answer by FireDragon for psql: could not connect to server: No such file or directory (Mac OS X)


this fixed the issue--I needed to delete this file, and then everything worked!

/usr/local/var/postgres/postmaster.pid  

... but be warned, if you delete postmaster.pid without making sure there are really no postgres processes running you could permanently corrupt your database. PostgreSQL should delete it automatically if the postmaster has exited. (Edit by CR)

--

and here is how I figured out why this needed to be deleted.

  1. first I used the following command to see if there were any PG processes running. for me there were none, I couldn't even start the PG server:

    ps auxw | grep post  
  2. second, i searched for the file .s.PGSQL.5432 that was in the error message above. i used the following command:

    sudo find / -name .s.PGSQL.5432 -ls  

    this didn't show anything after searching my whole computer so the file didn't exist, but obviously psql "wanted it to" or "thought it was there".

  3. third, i took a look at my server logs and saw the following error:

    cat /usr/local/var/postgres/server.log  

    at the end of the server log I see the following error:

    FATAL:  pre-existing shared memory block (key 5432001, ID 65538) is still in use  HINT:  If you're sure there are no old server processes still running, remove the shared memory block or just delete the file "postmaster.pid".  
  4. Following the advice in the error message, I deleted the postmaster.pid file in the same directory as server.log. This resolved the issue and I was able to restart.

So, it seems that my macbook freezing and being hard-rebooted caused Postgres to think that it's processes were still running even after reboot. Deleting this file resolved. Hope this helps others! Lots of people have similar issues but most the answers had to do with file permissions, whereas in my case things were different.

Answer by crazzyaka for psql: could not connect to server: No such file or directory (Mac OS X)


Hello world :)
The best but strange way for me was to do next things.

1) Download postgres93.app or other version. Add this app into /Applications/ folder.

2) Add a row (command) into the file .bash_profile (which is in my home directory):

export PATH=/Applications/Postgres93.app/Contents/MacOS/bin/:$PATH
It's a PATH to psql from Postgres93.app. The row (command) runs every time console is started.

3) Launch Postgres93.app from /Applications/ folder. It starts a local server (port is "5432" and host is "localhost").

4) After all of this manipulations I was glad to run $ createuser -SRDP user_name and other commands and to see that it worked! Postgres93.app can be made to run every time your system starts.

5) Also if you wanna see your databases graphically you should install PG Commander.app. It's good way to see your postgres DB as pretty data-tables

Of, course, it's helpful only for local server. I will be glad if this instructions help others who has faced with this problem.

Answer by Jerome for psql: could not connect to server: No such file or directory (Mac OS X)


This problema has many sources, and thus many answers. I've experienced each one of them.

1) If you have a crash of some sort, removing the /usr/local/var/postgres/postmaster.pid file is probably required as postgres may not have handled it properly. But ensure that no process is running.

2) Craig Ringer has pointed out in other posts that Apple's bundling of postgreSQL leads to pg gem installation issues Setting the PATH environment variable is a solution.

3) Another solution, is to uninstall and reinstall the gem. A brew update may be necessary as well.

If you stumble upon this post, if you can pinpoint one of the sources, you'll save time...

Answer by cohart for psql: could not connect to server: No such file or directory (Mac OS X)


I've had to look up this post several times to solve this issue. There's another fix, which will also applies to similar issues with other running programs.

I just discovered you can use the following two commands.

$top

This will show all the currently running actions with their pid numbers. When you find postgres and the associated pid

$kill pid_number

Answer by Gagan Gami for psql: could not connect to server: No such file or directory (Mac OS X)


I just got the same issue as I have put my machine(ubuntu) for update and got below error:

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"?

After completing the updating process when I restart my system error gone. And its work like charm as before.. I guess this was happened as pg was updating and another process started.

Answer by Jagdish Barabari for psql: could not connect to server: No such file or directory (Mac OS X)


I was facing a similar issue here I solved this issue as below.

Actually the postgres process is dead, to see the status of postgres run the following command

sudo /etc/init.d/postgres status  

It will says the process is dead`just start the process

sudo /etc/init.d/postgres start  

Answer by Jagdish Barabari for psql: could not connect to server: No such file or directory (Mac OS X)


Just restart the server by running

$sudo service postgresql restart    

or

sudo /etc/init.d/postgresql restart  

Answer by jawns317 for psql: could not connect to server: No such file or directory (Mac OS X)


My problem ended up being that I was using Gas Mask (a hosts file manager for Mac), and I didn't have an entry for localhost in the hosts file I was using.

I added:

127.0.0.1 localhost  

And that resolved my problem.

Answer by Lorenzo for psql: could not connect to server: No such file or directory (Mac OS X)


SUPER NEWBIE ALERT: I'm just learning web development and the particular tutorial I was following mentioned I have to install Postgres but didn't actually mention I have to run it as well... Once I opened the Postgres application everything was fine and dandy.

Answer by Ignacio Chiazzo for psql: could not connect to server: No such file or directory (Mac OS X)


I know that it is an old question but I tried with these solutions and none of them worked, the solution was reInstall http://postgresapp.com/ (updating to the latest version) this app. I am using OS Yosemite.

Answer by 5280Angel for psql: could not connect to server: No such file or directory (Mac OS X)


@Jagdish Barabari's answer gave me the clue I needed to resolve this. Turns out there were two versions of postgresql installed while only one was running. Purging all postgresql files and reinstalling the latest version resolved this issue for me.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.