Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake aborted, Could not connect do postgresql: connection refused

I am trying to execute the rake command on my brand new rails project with postgresql but I am getting this error:

rake aborted! 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?

Tasks: TOP => db:migrate (See full trace by running task with --trace)

real 0m3.245s user 0m1.668s sys 0m0.382s

This is my first rails app ever, whe I run rails server this is the output:

=> Booting WEBrick

=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server [2012-06-19 01:17:30] INFO WEBrick 1.3.1 [2012-06-19 01:17:30] INFO ruby 1.9.3 (2012-04-20)

[x86_64-darwin11.3.0] [2012-06-19 01:17:30] INFO

WEBrick::HTTPServer#start: pid=4668 port=3000

Rails -v: Rails 3.2.3

gem env:

RubyGems Environment: - RUBYGEMS VERSION: 1.8.24 - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.3.0] - INSTALLATION DIRECTORY: /Users/kinhow/.rvm/gems/ruby-1.9.3-p194 - RUBY EXECUTABLE: /Users/kinhow/.rvm/rubies/ruby-1.9.3-p194/bin/ruby - EXECUTABLE DIRECTORY: /Users/kinhow/.rvm/gems/ruby-1.9.3-p194/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-11 - GEM PATHS: - /Users/kinhow/.rvm/gems/ruby-1.9.3-p194 - /Users/kinhow/.rvm/gems/ruby-1.9.3-p194@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/

if it helps:

running psql

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

like image 585
Andre Cytryn Avatar asked Oct 08 '22 11:10

Andre Cytryn


1 Answers

First, you need to ensure that postgresql is running. Open a console and do a "ps auxw | grep post" and make sure that the server is running. You should have at least four processes running including "postgres: writer process". If you don't then you haven't started it. Even if you have started it, you must have it configured to listen on an appropriate port (127.0.0.1 and "localhost"). Did you edit the postgres.conf file and the pg_hba.conf files? If you did, did you restart the server? Are you using the latest pg gem? How do you start your server?

~Charles~

like image 72
thisfeller Avatar answered Oct 12 '22 22:10

thisfeller