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












164
















Upon restarting my Mac 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.










share|improve this question
























  • As a sanity check, make sure you have PG running on your machine
    – Jbur43
    Dec 18 '15 at 19:10






  • 1




    When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
    – Nick Res
    Jun 4 at 13:48
















164
















Upon restarting my Mac 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.










share|improve this question
























  • As a sanity check, make sure you have PG running on your machine
    – Jbur43
    Dec 18 '15 at 19:10






  • 1




    When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
    – Nick Res
    Jun 4 at 13:48














164












164








164


69







Upon restarting my Mac 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.










share|improve this question

















Upon restarting my Mac 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.







macos postgresql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 30 '17 at 19:56









ken

2,85412031




2,85412031










asked Nov 26 '12 at 21:09









FireDragon

5,03332131




5,03332131












  • As a sanity check, make sure you have PG running on your machine
    – Jbur43
    Dec 18 '15 at 19:10






  • 1




    When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
    – Nick Res
    Jun 4 at 13:48


















  • As a sanity check, make sure you have PG running on your machine
    – Jbur43
    Dec 18 '15 at 19:10






  • 1




    When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
    – Nick Res
    Jun 4 at 13:48
















As a sanity check, make sure you have PG running on your machine
– Jbur43
Dec 18 '15 at 19:10




As a sanity check, make sure you have PG running on your machine
– Jbur43
Dec 18 '15 at 19:10




1




1




When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
– Nick Res
Jun 4 at 13:48




When you leave the answer please try to explain WHY this is happening, or how the Postgres system work so we're not all just trying random stuff.
– Nick Res
Jun 4 at 13:48












18 Answers
18






active

oldest

votes


















315














WARNING: 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.).



SOLUTION: This fixed the issue--I deleted this file, and then everything worked!



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


--



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





  1. 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. 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. 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.






share|improve this answer



















  • 7




    hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
    – FireDragon
    Nov 28 '12 at 3:59






  • 2




    Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
    – Craig Ringer
    Jun 7 '13 at 0:19






  • 2




    thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
    – Yurui Ray Zhang
    Oct 25 '13 at 18:12






  • 13




    Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
    – dojosto
    Apr 13 '14 at 22:29






  • 3




    Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
    – Clinton Judy
    Jun 18 '14 at 15:52



















63














If you're on macOS and installed postgres via homebrew, try restarting it with



brew services restart postgresql


If you're on Ubuntu, you can restart it with either one of these commands



sudo service postgresql restart

sudo /etc/init.d/postgresql restart





share|improve this answer



















  • 2




    Did not work for me
    – Babalola Rotimi
    May 8 '17 at 13:06



















52














None of the above worked for me. I had to reinstall Postgres the following way :




  • Uninstall postgresql with brew : brew uninstall postgresql


  • brew doctor (fix whatever is here)

  • brew prune


  • Remove all Postgres folders :




    • rm -r /usr/local/var/postgres

    • rm -r /Users/<username>/Library/Application Support/Postgres



  • Reinstall postgresql with brew : brew install postgresql


  • Start server : brew services start postgresql

  • You should now have to create your databases... (createdb)






share|improve this answer



















  • 2




    this is the right answer! needs more upvotes!!!
    – PirateApp
    May 19 at 5:23










  • The other answers didn't work for me. It was brew that was a bit broken :) Thank.
    – Johan
    Sep 9 at 3:16










  • This answer worked for me. Thanks!
    – Ian Shiundu
    Sep 23 at 13:13










  • This worked for me also. +1
    – Adrian Muntean
    Oct 29 at 11:08










  • you legend, worked a treat 👍
    – David Chiew
    Nov 7 at 3:22



















7














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.






share|improve this answer



















  • 1




    The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
    – Tina
    Mar 14 '15 at 4:19





















7














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...






share|improve this answer



















  • 3




    I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
    – Jerome
    Mar 28 '14 at 14:58



















6














if your postmaster.pid is gone and you can't restart or anything, do this:



pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start



as explained here initially






share|improve this answer





























    5














    Maybe this is unrelated but a similar error appears when you upgrade postgre to a major version using brew; using brew info postgresql found out this that helped:



    To migrate existing data from a previous major version of PostgreSQL run:
    brew postgresql-upgrade-database





    share|improve this answer





















    • it works! thanks
      – Penguin
      Dec 17 at 7:38



















    4














    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





    share|improve this answer





















    • Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
      – Pravitha V
      Feb 9 '17 at 11:15





















    4














    For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.






    share|improve this answer





























      3














      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.






      share|improve this answer





























        3














        This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.






        share|improve this answer





























          1














          I had the same issue.
          Most of the times, the problem is the fact that there's a leftover file



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



          which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.



          Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:



          Error: Permission denied @ rb_sysopen - /private/tmp/github_api_....



          or something like it at the end of an install.



          I simply did sudo chmod -R 777 /private/tmp and it finally works!



          I'm writing this down because this might be a solution for someone else






          share|improve this answer





























            0














            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






            share|improve this answer





























              0














              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.






              share|improve this answer





























                0














                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.






                share|improve this answer





























                  0














                  @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.






                  share|improve this answer





























                    0














                    The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.






                    share|improve this answer





























                      0














                      I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.



                      Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.



                      I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:



                      initdb /usr/local/var/postgres


                      It seems some configurations took place with that command.



                      Then it asked me to run this:



                      postgres -D /usr/local/var/postgres


                      And that told me a postmaster.pid file already exists.



                      I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.



                      ls /usr/local/var/postgres


                      That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.



                      Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.



                      Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.



                      Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.






                      share|improve this answer





















                        Your Answer






                        StackExchange.ifUsing("editor", function () {
                        StackExchange.using("externalEditor", function () {
                        StackExchange.using("snippets", function () {
                        StackExchange.snippets.init();
                        });
                        });
                        }, "code-snippets");

                        StackExchange.ready(function() {
                        var channelOptions = {
                        tags: "".split(" "),
                        id: "1"
                        };
                        initTagRenderer("".split(" "), "".split(" "), channelOptions);

                        StackExchange.using("externalEditor", function() {
                        // Have to fire editor after snippets, if snippets enabled
                        if (StackExchange.settings.snippets.snippetsEnabled) {
                        StackExchange.using("snippets", function() {
                        createEditor();
                        });
                        }
                        else {
                        createEditor();
                        }
                        });

                        function createEditor() {
                        StackExchange.prepareEditor({
                        heartbeatType: 'answer',
                        autoActivateHeartbeat: false,
                        convertImagesToLinks: true,
                        noModals: true,
                        showLowRepImageUploadWarning: true,
                        reputationToPostImages: 10,
                        bindNavPrevention: true,
                        postfix: "",
                        imageUploader: {
                        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                        allowUrls: true
                        },
                        onDemand: true,
                        discardSelector: ".discard-answer"
                        ,immediatelyShowMarkdownHelp:true
                        });


                        }
                        });














                        draft saved

                        draft discarded


















                        StackExchange.ready(
                        function () {
                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13573204%2fpsql-could-not-connect-to-server-no-such-file-or-directory-mac-os-x%23new-answer', 'question_page');
                        }
                        );

                        Post as a guest















                        Required, but never shown

























                        18 Answers
                        18






                        active

                        oldest

                        votes








                        18 Answers
                        18






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes









                        315














                        WARNING: 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.).



                        SOLUTION: This fixed the issue--I deleted this file, and then everything worked!



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


                        --



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





                        1. 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. 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. 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.






                        share|improve this answer



















                        • 7




                          hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                          – FireDragon
                          Nov 28 '12 at 3:59






                        • 2




                          Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                          – Craig Ringer
                          Jun 7 '13 at 0:19






                        • 2




                          thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                          – Yurui Ray Zhang
                          Oct 25 '13 at 18:12






                        • 13




                          Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                          – dojosto
                          Apr 13 '14 at 22:29






                        • 3




                          Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                          – Clinton Judy
                          Jun 18 '14 at 15:52
















                        315














                        WARNING: 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.).



                        SOLUTION: This fixed the issue--I deleted this file, and then everything worked!



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


                        --



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





                        1. 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. 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. 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.






                        share|improve this answer



















                        • 7




                          hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                          – FireDragon
                          Nov 28 '12 at 3:59






                        • 2




                          Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                          – Craig Ringer
                          Jun 7 '13 at 0:19






                        • 2




                          thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                          – Yurui Ray Zhang
                          Oct 25 '13 at 18:12






                        • 13




                          Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                          – dojosto
                          Apr 13 '14 at 22:29






                        • 3




                          Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                          – Clinton Judy
                          Jun 18 '14 at 15:52














                        315












                        315








                        315






                        WARNING: 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.).



                        SOLUTION: This fixed the issue--I deleted this file, and then everything worked!



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


                        --



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





                        1. 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. 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. 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.






                        share|improve this answer














                        WARNING: 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.).



                        SOLUTION: This fixed the issue--I deleted this file, and then everything worked!



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


                        --



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





                        1. 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. 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. 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.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 18 '17 at 14:26









                        Flip

                        2,29221941




                        2,29221941










                        answered Nov 26 '12 at 21:09









                        FireDragon

                        5,03332131




                        5,03332131








                        • 7




                          hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                          – FireDragon
                          Nov 28 '12 at 3:59






                        • 2




                          Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                          – Craig Ringer
                          Jun 7 '13 at 0:19






                        • 2




                          thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                          – Yurui Ray Zhang
                          Oct 25 '13 at 18:12






                        • 13




                          Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                          – dojosto
                          Apr 13 '14 at 22:29






                        • 3




                          Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                          – Clinton Judy
                          Jun 18 '14 at 15:52














                        • 7




                          hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                          – FireDragon
                          Nov 28 '12 at 3:59






                        • 2




                          Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                          – Craig Ringer
                          Jun 7 '13 at 0:19






                        • 2




                          thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                          – Yurui Ray Zhang
                          Oct 25 '13 at 18:12






                        • 13




                          Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                          – dojosto
                          Apr 13 '14 at 22:29






                        • 3




                          Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                          – Clinton Judy
                          Jun 18 '14 at 15:52








                        7




                        7




                        hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                        – FireDragon
                        Nov 28 '12 at 3:59




                        hopefully this answer ends up helping someone else out, and thank you to the person that upvoted it. despite the moderator who marked this question as a duplicate it is unique and useful. thanks stack overflow for the awesome site and the experts on here for sharing!
                        – FireDragon
                        Nov 28 '12 at 3:59




                        2




                        2




                        Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                        – Craig Ringer
                        Jun 7 '13 at 0:19




                        Just FWIW, deleting postmaster.pid is dangerous, you've got to be really sure there are no postgres processes running before you do it.
                        – Craig Ringer
                        Jun 7 '13 at 0:19




                        2




                        2




                        thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                        – Yurui Ray Zhang
                        Oct 25 '13 at 18:12




                        thank you sir for saving my life...somehow my mac osx crashed and when it restarted postgres session was not killed.
                        – Yurui Ray Zhang
                        Oct 25 '13 at 18:12




                        13




                        13




                        Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                        – dojosto
                        Apr 13 '14 at 22:29




                        Great answer. Thanks for posting your entire process rather than just the potentially destructive command!
                        – dojosto
                        Apr 13 '14 at 22:29




                        3




                        3




                        Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                        – Clinton Judy
                        Jun 18 '14 at 15:52




                        Agreed. The answer about postmaster.pid is good, but each step of the process of figuring out if/where postgres is running, is invaluable. Thank you!
                        – Clinton Judy
                        Jun 18 '14 at 15:52













                        63














                        If you're on macOS and installed postgres via homebrew, try restarting it with



                        brew services restart postgresql


                        If you're on Ubuntu, you can restart it with either one of these commands



                        sudo service postgresql restart

                        sudo /etc/init.d/postgresql restart





                        share|improve this answer



















                        • 2




                          Did not work for me
                          – Babalola Rotimi
                          May 8 '17 at 13:06
















                        63














                        If you're on macOS and installed postgres via homebrew, try restarting it with



                        brew services restart postgresql


                        If you're on Ubuntu, you can restart it with either one of these commands



                        sudo service postgresql restart

                        sudo /etc/init.d/postgresql restart





                        share|improve this answer



















                        • 2




                          Did not work for me
                          – Babalola Rotimi
                          May 8 '17 at 13:06














                        63












                        63








                        63






                        If you're on macOS and installed postgres via homebrew, try restarting it with



                        brew services restart postgresql


                        If you're on Ubuntu, you can restart it with either one of these commands



                        sudo service postgresql restart

                        sudo /etc/init.d/postgresql restart





                        share|improve this answer














                        If you're on macOS and installed postgres via homebrew, try restarting it with



                        brew services restart postgresql


                        If you're on Ubuntu, you can restart it with either one of these commands



                        sudo service postgresql restart

                        sudo /etc/init.d/postgresql restart






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Oct 31 at 0:46









                        Boris

                        1,0871327




                        1,0871327










                        answered Jun 15 '15 at 9:12









                        Jagdish Barabari

                        1,92621421




                        1,92621421








                        • 2




                          Did not work for me
                          – Babalola Rotimi
                          May 8 '17 at 13:06














                        • 2




                          Did not work for me
                          – Babalola Rotimi
                          May 8 '17 at 13:06








                        2




                        2




                        Did not work for me
                        – Babalola Rotimi
                        May 8 '17 at 13:06




                        Did not work for me
                        – Babalola Rotimi
                        May 8 '17 at 13:06











                        52














                        None of the above worked for me. I had to reinstall Postgres the following way :




                        • Uninstall postgresql with brew : brew uninstall postgresql


                        • brew doctor (fix whatever is here)

                        • brew prune


                        • Remove all Postgres folders :




                          • rm -r /usr/local/var/postgres

                          • rm -r /Users/<username>/Library/Application Support/Postgres



                        • Reinstall postgresql with brew : brew install postgresql


                        • Start server : brew services start postgresql

                        • You should now have to create your databases... (createdb)






                        share|improve this answer



















                        • 2




                          this is the right answer! needs more upvotes!!!
                          – PirateApp
                          May 19 at 5:23










                        • The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                          – Johan
                          Sep 9 at 3:16










                        • This answer worked for me. Thanks!
                          – Ian Shiundu
                          Sep 23 at 13:13










                        • This worked for me also. +1
                          – Adrian Muntean
                          Oct 29 at 11:08










                        • you legend, worked a treat 👍
                          – David Chiew
                          Nov 7 at 3:22
















                        52














                        None of the above worked for me. I had to reinstall Postgres the following way :




                        • Uninstall postgresql with brew : brew uninstall postgresql


                        • brew doctor (fix whatever is here)

                        • brew prune


                        • Remove all Postgres folders :




                          • rm -r /usr/local/var/postgres

                          • rm -r /Users/<username>/Library/Application Support/Postgres



                        • Reinstall postgresql with brew : brew install postgresql


                        • Start server : brew services start postgresql

                        • You should now have to create your databases... (createdb)






                        share|improve this answer



















                        • 2




                          this is the right answer! needs more upvotes!!!
                          – PirateApp
                          May 19 at 5:23










                        • The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                          – Johan
                          Sep 9 at 3:16










                        • This answer worked for me. Thanks!
                          – Ian Shiundu
                          Sep 23 at 13:13










                        • This worked for me also. +1
                          – Adrian Muntean
                          Oct 29 at 11:08










                        • you legend, worked a treat 👍
                          – David Chiew
                          Nov 7 at 3:22














                        52












                        52








                        52






                        None of the above worked for me. I had to reinstall Postgres the following way :




                        • Uninstall postgresql with brew : brew uninstall postgresql


                        • brew doctor (fix whatever is here)

                        • brew prune


                        • Remove all Postgres folders :




                          • rm -r /usr/local/var/postgres

                          • rm -r /Users/<username>/Library/Application Support/Postgres



                        • Reinstall postgresql with brew : brew install postgresql


                        • Start server : brew services start postgresql

                        • You should now have to create your databases... (createdb)






                        share|improve this answer














                        None of the above worked for me. I had to reinstall Postgres the following way :




                        • Uninstall postgresql with brew : brew uninstall postgresql


                        • brew doctor (fix whatever is here)

                        • brew prune


                        • Remove all Postgres folders :




                          • rm -r /usr/local/var/postgres

                          • rm -r /Users/<username>/Library/Application Support/Postgres



                        • Reinstall postgresql with brew : brew install postgresql


                        • Start server : brew services start postgresql

                        • You should now have to create your databases... (createdb)







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 1 '17 at 18:25









                        wilbeibi

                        2,28922034




                        2,28922034










                        answered Oct 27 '17 at 9:30









                        ypicard

                        944723




                        944723








                        • 2




                          this is the right answer! needs more upvotes!!!
                          – PirateApp
                          May 19 at 5:23










                        • The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                          – Johan
                          Sep 9 at 3:16










                        • This answer worked for me. Thanks!
                          – Ian Shiundu
                          Sep 23 at 13:13










                        • This worked for me also. +1
                          – Adrian Muntean
                          Oct 29 at 11:08










                        • you legend, worked a treat 👍
                          – David Chiew
                          Nov 7 at 3:22














                        • 2




                          this is the right answer! needs more upvotes!!!
                          – PirateApp
                          May 19 at 5:23










                        • The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                          – Johan
                          Sep 9 at 3:16










                        • This answer worked for me. Thanks!
                          – Ian Shiundu
                          Sep 23 at 13:13










                        • This worked for me also. +1
                          – Adrian Muntean
                          Oct 29 at 11:08










                        • you legend, worked a treat 👍
                          – David Chiew
                          Nov 7 at 3:22








                        2




                        2




                        this is the right answer! needs more upvotes!!!
                        – PirateApp
                        May 19 at 5:23




                        this is the right answer! needs more upvotes!!!
                        – PirateApp
                        May 19 at 5:23












                        The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                        – Johan
                        Sep 9 at 3:16




                        The other answers didn't work for me. It was brew that was a bit broken :) Thank.
                        – Johan
                        Sep 9 at 3:16












                        This answer worked for me. Thanks!
                        – Ian Shiundu
                        Sep 23 at 13:13




                        This answer worked for me. Thanks!
                        – Ian Shiundu
                        Sep 23 at 13:13












                        This worked for me also. +1
                        – Adrian Muntean
                        Oct 29 at 11:08




                        This worked for me also. +1
                        – Adrian Muntean
                        Oct 29 at 11:08












                        you legend, worked a treat 👍
                        – David Chiew
                        Nov 7 at 3:22




                        you legend, worked a treat 👍
                        – David Chiew
                        Nov 7 at 3:22











                        7














                        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.






                        share|improve this answer



















                        • 1




                          The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                          – Tina
                          Mar 14 '15 at 4:19


















                        7














                        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.






                        share|improve this answer



















                        • 1




                          The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                          – Tina
                          Mar 14 '15 at 4:19
















                        7












                        7








                        7






                        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.






                        share|improve this answer














                        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.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 1 '14 at 21:38

























                        answered Feb 1 '14 at 20:38









                        crazzyaka

                        52655




                        52655








                        • 1




                          The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                          – Tina
                          Mar 14 '15 at 4:19
















                        • 1




                          The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                          – Tina
                          Mar 14 '15 at 4:19










                        1




                        1




                        The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                        – Tina
                        Mar 14 '15 at 4:19






                        The key here is adding Postgres to your path (step 2). That helped me. If you installed Postgres using Homebrew, you can add it to your path by adding the following line to your .bash_profile: export PATH='/usr/local/Cellar/postgresql/9.4.1/bin/':$PATH – Keep in mind your version number may be different.
                        – Tina
                        Mar 14 '15 at 4:19













                        7














                        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...






                        share|improve this answer



















                        • 3




                          I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                          – Jerome
                          Mar 28 '14 at 14:58
















                        7














                        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...






                        share|improve this answer



















                        • 3




                          I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                          – Jerome
                          Mar 28 '14 at 14:58














                        7












                        7








                        7






                        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...






                        share|improve this answer














                        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...







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 23 '17 at 12:34









                        Community

                        11




                        11










                        answered Mar 11 '14 at 8:53









                        Jerome

                        2,1051831




                        2,1051831








                        • 3




                          I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                          – Jerome
                          Mar 28 '14 at 14:58














                        • 3




                          I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                          – Jerome
                          Mar 28 '14 at 14:58








                        3




                        3




                        I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                        – Jerome
                        Mar 28 '14 at 14:58




                        I'm glad I posted this. Another crash & the answer can be retreived rather quickly...
                        – Jerome
                        Mar 28 '14 at 14:58











                        6














                        if your postmaster.pid is gone and you can't restart or anything, do this:



                        pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start



                        as explained here initially






                        share|improve this answer


























                          6














                          if your postmaster.pid is gone and you can't restart or anything, do this:



                          pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start



                          as explained here initially






                          share|improve this answer
























                            6












                            6








                            6






                            if your postmaster.pid is gone and you can't restart or anything, do this:



                            pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start



                            as explained here initially






                            share|improve this answer












                            if your postmaster.pid is gone and you can't restart or anything, do this:



                            pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start



                            as explained here initially







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 5 '17 at 1:00









                            Antoine

                            434410




                            434410























                                5














                                Maybe this is unrelated but a similar error appears when you upgrade postgre to a major version using brew; using brew info postgresql found out this that helped:



                                To migrate existing data from a previous major version of PostgreSQL run:
                                brew postgresql-upgrade-database





                                share|improve this answer





















                                • it works! thanks
                                  – Penguin
                                  Dec 17 at 7:38
















                                5














                                Maybe this is unrelated but a similar error appears when you upgrade postgre to a major version using brew; using brew info postgresql found out this that helped:



                                To migrate existing data from a previous major version of PostgreSQL run:
                                brew postgresql-upgrade-database





                                share|improve this answer





















                                • it works! thanks
                                  – Penguin
                                  Dec 17 at 7:38














                                5












                                5








                                5






                                Maybe this is unrelated but a similar error appears when you upgrade postgre to a major version using brew; using brew info postgresql found out this that helped:



                                To migrate existing data from a previous major version of PostgreSQL run:
                                brew postgresql-upgrade-database





                                share|improve this answer












                                Maybe this is unrelated but a similar error appears when you upgrade postgre to a major version using brew; using brew info postgresql found out this that helped:



                                To migrate existing data from a previous major version of PostgreSQL run:
                                brew postgresql-upgrade-database






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jul 31 at 10:52









                                Crazy Barney

                                1601412




                                1601412












                                • it works! thanks
                                  – Penguin
                                  Dec 17 at 7:38


















                                • it works! thanks
                                  – Penguin
                                  Dec 17 at 7:38
















                                it works! thanks
                                – Penguin
                                Dec 17 at 7:38




                                it works! thanks
                                – Penguin
                                Dec 17 at 7:38











                                4














                                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





                                share|improve this answer





















                                • Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                  – Pravitha V
                                  Feb 9 '17 at 11:15


















                                4














                                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





                                share|improve this answer





















                                • Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                  – Pravitha V
                                  Feb 9 '17 at 11:15
















                                4












                                4








                                4






                                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





                                share|improve this answer












                                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






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered May 13 '15 at 10:05









                                Jagdish Barabari

                                1,92621421




                                1,92621421












                                • Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                  – Pravitha V
                                  Feb 9 '17 at 11:15




















                                • Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                  – Pravitha V
                                  Feb 9 '17 at 11:15


















                                Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                – Pravitha V
                                Feb 9 '17 at 11:15






                                Thankyou for the answer, your answer helped me solve the same issue with some modifications: sudo /etc/init.d/postgresql start
                                – Pravitha V
                                Feb 9 '17 at 11:15













                                4














                                For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.






                                share|improve this answer


























                                  4














                                  For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.






                                  share|improve this answer
























                                    4












                                    4








                                    4






                                    For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.






                                    share|improve this answer












                                    For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 8 '17 at 4:47









                                    Matt Lemieux

                                    30629




                                    30629























                                        3














                                        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.






                                        share|improve this answer


























                                          3














                                          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.






                                          share|improve this answer
























                                            3












                                            3








                                            3






                                            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.






                                            share|improve this answer












                                            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.







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Jul 22 '15 at 18:00









                                            jawns317

                                            83621021




                                            83621021























                                                3














                                                This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.






                                                share|improve this answer


























                                                  3














                                                  This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.






                                                  share|improve this answer
























                                                    3












                                                    3








                                                    3






                                                    This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.






                                                    share|improve this answer












                                                    This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Oct 20 '17 at 15:45









                                                    skwidbreth

                                                    2,39711554




                                                    2,39711554























                                                        1














                                                        I had the same issue.
                                                        Most of the times, the problem is the fact that there's a leftover file



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



                                                        which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.



                                                        Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:



                                                        Error: Permission denied @ rb_sysopen - /private/tmp/github_api_....



                                                        or something like it at the end of an install.



                                                        I simply did sudo chmod -R 777 /private/tmp and it finally works!



                                                        I'm writing this down because this might be a solution for someone else






                                                        share|improve this answer


























                                                          1














                                                          I had the same issue.
                                                          Most of the times, the problem is the fact that there's a leftover file



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



                                                          which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.



                                                          Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:



                                                          Error: Permission denied @ rb_sysopen - /private/tmp/github_api_....



                                                          or something like it at the end of an install.



                                                          I simply did sudo chmod -R 777 /private/tmp and it finally works!



                                                          I'm writing this down because this might be a solution for someone else






                                                          share|improve this answer
























                                                            1












                                                            1








                                                            1






                                                            I had the same issue.
                                                            Most of the times, the problem is the fact that there's a leftover file



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



                                                            which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.



                                                            Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:



                                                            Error: Permission denied @ rb_sysopen - /private/tmp/github_api_....



                                                            or something like it at the end of an install.



                                                            I simply did sudo chmod -R 777 /private/tmp and it finally works!



                                                            I'm writing this down because this might be a solution for someone else






                                                            share|improve this answer












                                                            I had the same issue.
                                                            Most of the times, the problem is the fact that there's a leftover file



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



                                                            which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.



                                                            Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:



                                                            Error: Permission denied @ rb_sysopen - /private/tmp/github_api_....



                                                            or something like it at the end of an install.



                                                            I simply did sudo chmod -R 777 /private/tmp and it finally works!



                                                            I'm writing this down because this might be a solution for someone else







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered yesterday









                                                            Maciej Pk

                                                            3810




                                                            3810























                                                                0














                                                                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






                                                                share|improve this answer


























                                                                  0














                                                                  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






                                                                  share|improve this answer
























                                                                    0












                                                                    0








                                                                    0






                                                                    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






                                                                    share|improve this answer












                                                                    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







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered Jul 18 '14 at 20:20









                                                                    cohart

                                                                    62110




                                                                    62110























                                                                        0














                                                                        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.






                                                                        share|improve this answer


























                                                                          0














                                                                          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.






                                                                          share|improve this answer
























                                                                            0












                                                                            0








                                                                            0






                                                                            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.






                                                                            share|improve this answer












                                                                            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.







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Mar 2 '15 at 5:42









                                                                            Gagan Gami

                                                                            8,32811641




                                                                            8,32811641























                                                                                0














                                                                                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.






                                                                                share|improve this answer


























                                                                                  0














                                                                                  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.






                                                                                  share|improve this answer
























                                                                                    0












                                                                                    0








                                                                                    0






                                                                                    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.






                                                                                    share|improve this answer












                                                                                    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.







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered May 1 '16 at 7:08









                                                                                    Lorenzo

                                                                                    409312




                                                                                    409312























                                                                                        0














                                                                                        @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.






                                                                                        share|improve this answer


























                                                                                          0














                                                                                          @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.






                                                                                          share|improve this answer
























                                                                                            0












                                                                                            0








                                                                                            0






                                                                                            @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.






                                                                                            share|improve this answer












                                                                                            @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.







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered May 11 '16 at 17:20









                                                                                            5280Angel

                                                                                            466




                                                                                            466























                                                                                                0














                                                                                                The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.






                                                                                                share|improve this answer


























                                                                                                  0














                                                                                                  The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.






                                                                                                  share|improve this answer
























                                                                                                    0












                                                                                                    0








                                                                                                    0






                                                                                                    The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.






                                                                                                    share|improve this answer












                                                                                                    The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.







                                                                                                    share|improve this answer












                                                                                                    share|improve this answer



                                                                                                    share|improve this answer










                                                                                                    answered Jan 26 at 16:54









                                                                                                    Tamlyn

                                                                                                    10.7k46599




                                                                                                    10.7k46599























                                                                                                        0














                                                                                                        I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.



                                                                                                        Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.



                                                                                                        I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:



                                                                                                        initdb /usr/local/var/postgres


                                                                                                        It seems some configurations took place with that command.



                                                                                                        Then it asked me to run this:



                                                                                                        postgres -D /usr/local/var/postgres


                                                                                                        And that told me a postmaster.pid file already exists.



                                                                                                        I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.



                                                                                                        ls /usr/local/var/postgres


                                                                                                        That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.



                                                                                                        Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.



                                                                                                        Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.



                                                                                                        Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.






                                                                                                        share|improve this answer


























                                                                                                          0














                                                                                                          I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.



                                                                                                          Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.



                                                                                                          I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:



                                                                                                          initdb /usr/local/var/postgres


                                                                                                          It seems some configurations took place with that command.



                                                                                                          Then it asked me to run this:



                                                                                                          postgres -D /usr/local/var/postgres


                                                                                                          And that told me a postmaster.pid file already exists.



                                                                                                          I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.



                                                                                                          ls /usr/local/var/postgres


                                                                                                          That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.



                                                                                                          Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.



                                                                                                          Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.



                                                                                                          Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.






                                                                                                          share|improve this answer
























                                                                                                            0












                                                                                                            0








                                                                                                            0






                                                                                                            I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.



                                                                                                            Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.



                                                                                                            I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:



                                                                                                            initdb /usr/local/var/postgres


                                                                                                            It seems some configurations took place with that command.



                                                                                                            Then it asked me to run this:



                                                                                                            postgres -D /usr/local/var/postgres


                                                                                                            And that told me a postmaster.pid file already exists.



                                                                                                            I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.



                                                                                                            ls /usr/local/var/postgres


                                                                                                            That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.



                                                                                                            Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.



                                                                                                            Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.



                                                                                                            Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.






                                                                                                            share|improve this answer












                                                                                                            I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.



                                                                                                            Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.



                                                                                                            I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:



                                                                                                            initdb /usr/local/var/postgres


                                                                                                            It seems some configurations took place with that command.



                                                                                                            Then it asked me to run this:



                                                                                                            postgres -D /usr/local/var/postgres


                                                                                                            And that told me a postmaster.pid file already exists.



                                                                                                            I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.



                                                                                                            ls /usr/local/var/postgres


                                                                                                            That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.



                                                                                                            Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.



                                                                                                            Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.



                                                                                                            Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.







                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered Jun 4 at 15:24









                                                                                                            Nick Res

                                                                                                            1,11532240




                                                                                                            1,11532240






























                                                                                                                draft saved

                                                                                                                draft discarded




















































                                                                                                                Thanks for contributing an answer to Stack Overflow!


                                                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                                                But avoid



                                                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                To learn more, see our tips on writing great answers.





                                                                                                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                                                Please pay close attention to the following guidance:


                                                                                                                • Please be sure to answer the question. Provide details and share your research!

                                                                                                                But avoid



                                                                                                                • Asking for help, clarification, or responding to other answers.

                                                                                                                • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                To learn more, see our tips on writing great answers.




                                                                                                                draft saved


                                                                                                                draft discarded














                                                                                                                StackExchange.ready(
                                                                                                                function () {
                                                                                                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13573204%2fpsql-could-not-connect-to-server-no-such-file-or-directory-mac-os-x%23new-answer', 'question_page');
                                                                                                                }
                                                                                                                );

                                                                                                                Post as a guest















                                                                                                                Required, but never shown





















































                                                                                                                Required, but never shown














                                                                                                                Required, but never shown












                                                                                                                Required, but never shown







                                                                                                                Required, but never shown

































                                                                                                                Required, but never shown














                                                                                                                Required, but never shown












                                                                                                                Required, but never shown







                                                                                                                Required, but never shown







                                                                                                                Popular posts from this blog

                                                                                                                Mossoró

                                                                                                                Error while reading .h5 file using the rhdf5 package in R

                                                                                                                Pushsharp Apns notification error: 'InvalidToken'