Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to deploy on heroku a simple blog I created with RoR for learning purposes and sqlite3 is not supported so I decided to migrate to PostgreSQL.

I changed my database.yml file

development:
adapter: postgresql
encoding: utf8
database: blog_development
pool: 5
username: user
password:

test:
adapter: postgresql
encoding: utf8
database: blog_test
pool: 5
username: user
password:

installed PostgreSQL using:

brew install postgresql

removed sqlite3 and added:

gem 'pg' 

and ran bundle install

when I tried running:

rake db:create

i got:

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?

I tried fixing it with:

In Rails, Couldn't create database for {"adapter"=>"postgresql",

and:

http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x

http://www.mozmorris.com/2011/11/15/configure-postgresql-to-accept-tcpip-connections.html

Addl. Info:

RoR: 4.0

Ruby: 2.0.0

psql: 9.3.1

pg: '0.17.0'

OS: OSX Mavericks

share|improve this question
 
Is PostgreSQL running? What does pgrep -lf postgres return? –  Kevin Sjöberg Nov 14 '13 at 19:20
 
Did you install pgAdmin (pgadmin.org/download/macosx.php)? That can help you make sure your postgres server is setup and running correctly. –  Dhaulagiri Nov 14 '13 at 19:21
 
Yes, used lunchy start postgresql –  gimiarn1801 Nov 14 '13 at 19:21
 
@KevinSjöberg doesn't return anything –  gimiarn1801 Nov 14 '13 at 19:22
 
Then postgres isn't running. Run pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start to start it. –  Kevin Sjöberg Nov 14 '13 at 19:23
show 1 more comment

2 Answers

up vote 0 down vote accepted

Make sure postgres is running

First Install postgres using homebrew(which you've already done)

brew install postgresql

Second: Create a new PostgreSQL database cluster

initdb /usr/local/var/postgres

Finally: Start postgresql

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
share|improve this answer
add comment

Maybe the 'user' user doesn't exist. On the command line, try this:

psql
psql=# create user name_here;
psql=# alter user name_here superuser;
psql=# \q
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.