Rake aborted, Could not connect do postgresql: connection refused - ruby-on-rails

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"?

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~

Related

Rails server is running but cannot connect to it in web browser in Ubuntu 14.04

I am new to Ubuntu 14.04. I am trying to set-up Ruby on Rails on Ubuntu 14.04 and I am using an Azure virtual machine. Everything is done. I installed Ruby, Rails and Bundler.
When I start the server it runs perfectly but I cannot see the "WELCOME ABOARD" or any start page and I cannot connect it through my browser.
When I run rails s Webrick starts successfully and it says:
=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
[2016-01-29 20:47:14] INFO WEBrick 1.3.1
[2016-01-29 20:47:14] INFO ruby 2.2.3 (2015-08-18) [x86_64-linux]
[2016-01-29 20:47:14] INFO WEBrick::HTTPServer#start: pid=1655 port=3000
I also tried binding it with my public address. I tried everything I know.
Cannot connect to localhost from aside.
Try start rails with following arguments:
rails s -b {PUBLIC IP} -p 3000
where {PUBLIC IP} is IP address of your server

Can't Start Rails Server in Windows

I am newbie in ruby on rails. I'm currently installing Ruby on Rails.
I've done all the steps until : bundle install.
Then i type rails server to start the rails server. From what I read in http://guides.rubyonrails.org/command_line.html, after i type rails server, it's supposed to show:
$ cd commandsapp
$ bin/rails server
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-08-07 02:00:01] INFO WEBrick 1.3.1
[2013-08-07 02:00:01] INFO ruby 2.0.0 (2013-06-27) [x86_64-darwin11.2.0]
[2013-08-07 02:00:01] INFO WEBrick::HTTPServer#start: pid=69680 port=3000
but in my Command Line it show this, instead:
So the rails server is not running and when i type localhost:3000 or localhost:8000 in the browser, it says unable to connect(probably because the server isn't running).
Sorry my bad language.
You need to create a rails app and change into that directory before you can run the server. Try this:
rails new commandsapp # the name can be anything you want
cd commandsapp
rails server
"rails new " creates a new folder with the default rails layout (app, db, log etc).
The Error: 'require' : cannot load such file -- sqlite3/sqlite3_native (LoadError)
==> You must insert gem sqlite3/sqlite3_native into gemfile, then bundle install again. Try with rails server.

rails commands and rake are dumping unwanted list of all gems

It is very strange. I even tried a brand new project:
rails new abc
cd abc
rails s
The output is:
=> Booting WEBrick
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
active_support/descendants_tracker
active_support/core_ext/module/delegation
active_support/core_ext/object/to_param
active_support/core_ext/regexp
... lots more here
active_support/core_ext/array/extract_options
rack/utils
action_controller/metal/exceptions
[2015-04-23 19:35:42] INFO WEBrick 1.3.1
[2015-04-23 19:35:42] INFO ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0]
[2015-04-23 19:35:42] INFO WEBrick::HTTPServer#start: pid=12738 port=3000
It doesn't break anything, but it makes reading output to debug very difficult.
It happens for all usage of rails and rake, in or out of bundle exec, but not bundle commands like bundle list or bundle install
Strangest thing... but it went away when I updated from rails 4.1.1 to rails 4.2.1

Rails web server not starting with rails 2.3.8

I have
ruby version 1.8.7
rails version 2.3.8
Ruby server is not starting up on executing following command.
[root#localhost demo]# ruby script/server -p 80 -d
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:80
[root#localhost demo]#
Why is this observed, how can it be resolved?

Rails console - process finished with exit code 0

Can't start rails console. When I'm trying to start it I 've got this message:
Loading development environment (Rails 3.2.12)
Process finished with exit code 0
It exits without any errors. But rails server starts without problems:
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-04-26 02:23:44] INFO WEBrick 1.3.1
[2013-04-26 02:23:44] INFO ruby 1.9.3 (2013-02-22) [x86_64-darwin12.2.0]
[2013-04-26 02:23:44] INFO WEBrick::HTTPServer#start: pid=2393 port=3000
I'm running Mac OS X with rvm.
Why rails console may not be working?
Did you try with bundle exec?
bundle exec rails c
If you're using RVM, try doing rvm implode and reinstall Ruby and Rails.

Resources