Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to postgresql database after upgrading to Yosemite 10.10

After updating to Yosemite 10.10 I cannot connect to my postgresql database. I run the rails console and try and get the first user but get this error...

>     ➜  game_golf git:(master) ✗ rails c
>     Loading development environment (Rails 4.1.4)
>     [1] pry(main)> User.first
>     PG::ConnectionBad: could not connect to server: Connection refused
>       Is the server running on host "localhost" (::1) and accepting
>       TCP/IP connections on port 5432?
>     could not connect to server: Connection refused
>       Is the server running on host "localhost" (127.0.0.1) and accepting
>       TCP/IP connections on port 5432?
>     from /Users/pauldornfeld/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
>     [2] pry(main)>

What do I do! I have tried to reinstall postgresql, reinstall homebrew. Please help!

like image 926
PDev Avatar asked Oct 19 '14 05:10

PDev


People also ask

Can not connect to postgres?

“Could not connect to server: Connection refused” To be sure that PostgreSQL is running, you can also restart it with systemctl restart postgresql. If this does not fix the problem, the most likely cause of this error is that PostgreSQL is not configured to allow TCP/IP connections.


2 Answers

I found this.

cd /usr/local/var/postgres mkdir pg_tblspc pg_twophase pg_stat_tmp 

It worked for me.

like image 98
daslicious Avatar answered Sep 28 '22 02:09

daslicious


Checking the server.log will show you what directories it's looking for. Adding them to your postgres directory should fix this. (Was going to comment above, but don't have enough reputation)

like image 38
esc_rtn Avatar answered Sep 28 '22 01:09

esc_rtn