Reputation: 131
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
Upvotes: 3
Views: 4768
Reputation: 2849
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
Upvotes: 2
Reputation: 1735
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
Upvotes: 1