3

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

6
  • Is PostgreSQL running? What does pgrep -lf postgres return? Commented Nov 14, 2013 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. Commented Nov 14, 2013 at 19:21
  • Yes, used lunchy start postgresql Commented Nov 14, 2013 at 19:21
  • @KevinSjöberg doesn't return anything Commented Nov 14, 2013 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. Commented Nov 14, 2013 at 19:23

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.