0

I'm 50 pages into 'Ruby on Rails Tutorial' and it instructs me to run the bundle exec rake db:migrate command. When I do, I get the below answer. I don't know if running the command with --trace gives any helpful info.

It seems that it has to do with using postgresql, but after that I'm completely over my head.

What can I do to get this to work?

Thanks a ton!

C:\Sites\rails_projects\demo_app>bundle exec rake db:migrate
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused (0x0000274D/1
0061)
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?

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

C:\Sites\rails_projects\demo_app>bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused (0x0000274D/1
0061)
        Is the server running on host "localhost" (::1) and accepting
        TCP/IP connections on port 5432?
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:831:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:831:in `connect'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:548:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:41:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection
'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection
'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_c
onnection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connec
tion'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:356:in `block in check
out'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:265:in `block in conne
ction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_conne
ction'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_handling.rb:79:in `retrieve_connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/connection_handling.rb:53:in `connection'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:863:in `initialize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:764:in `new'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:764:in `up'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/migration.rb:742:in `migrate'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/acti
ve_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:150:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:106:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:100:in `top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:78:in `block in run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.2.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
Scott Pantall
  • 77
  • 2
  • 11

2 Answers2

2

This question is a possible duplicate of

PG::ConnectionBad - could not connect to server: Connection refused

I quess you'll find your answer there, but because you are on windows you might not.

I developed rails on windows for a while. It is pure pain. Just wait until you get into testing

You should install viritualbox with ubuntu (or other unix based operating system) and do you rails development from there.

Here are some links to get you started with vbox( short for viritualbox)

http://virtualboxes.org/images/ubuntu/

http://www.wikihow.com/Install-Ubuntu-on-VirtualBox

http://www.psychocats.net/ubuntu/virtualbox

Community
  • 1
  • 1
Andreas Lyngstad
  • 4,887
  • 2
  • 36
  • 69
  • Thanks! I did check out that post and the differences in OS does make a difference, so it wasn't as helpful as I'd like. My issue has to do with postgresql, because my app where I used the default, sqlite3, works. I just don't know anything about postgresql to troubleshoot it. – Scott Pantall Mar 29 '14 at 14:34
  • Developing Rails on Windows is indeed pure pain. I've experienced the same. – Magne Jul 19 '15 at 06:32
0

Only after I reach out for help do I realize that I misread my tutorial. /facepalm

My tutorial asked me to add

group :production do
  gem 'pg', '0.12.2'
end

instead of doing that, I replaced gem 'sqlite3' with gem 'pg' and that caused mass confusion and hysteria which caused the rake command not to work correctly.

Thanks everyone for your help!

Scott Pantall
  • 77
  • 2
  • 11