I tried to start amqp with the correct amqp credential but it fails. I have started rabbitmq server at port 5678 and I am using amqp gem of version 0.7.0 and I am using ruby-1.9.2
Here are the logs for what I have done in irb
± irb
/Users/ckgagan/.rvm/rubies/ruby-1.9.2-p320/bin/irb:4: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
1.9.2-p320 :001 > require 'mq'
=> true
1.9.2-p320 :002 > AMQP.start({"host"=>"localhost", "port"=>5678, "user"=>"username", "password"=>"password"}) do
1.9.2-p320 :003 > puts "hello"
1.9.2-p320 :004?> end
AMQP::Error: Could not connect to server 127.0.0.1:5672
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:76:in `block in initialize'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:107:in `call'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:107:in `block in unbind'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `call'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `block in run_deferred_callbacks'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `times'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `run_deferred_callbacks'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320#my_gemset/gems/amqp-0.7.0/lib/amqp.rb:81:in `start'
from (irb):2
from /Users/ckgagan/.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in `<main>'
Even though I tried to connect Rabbitmq server at 5678, its trying to connect to default port
Could not connect to server 127.0.0.1:5672
Why is it trying to connect to port 5672 even though I specified port 5678?
I am unable to figure this out and stuck here
Thanks
The AMQP configuration hash takes symbols as keys, not strings.
require "amqp"
AMQP.start({:host => "localhost", :port => 5678}) do
puts "hello"
end
Also, you might want to consider upgrading to a more recent version of the gem. The CHANGELOG for 0.7 to 0.9.x or 1.0.0 is a couple of pages long.
Related
I have run elasticsearch on port 8081 in cloud9.
/workspace/elasticsearch-6.1.1/bin $ ./elasticsearch -E http.port=8081
I then add 'searchkick' gem in gemfile and then bundle install
I then add searchkick in model as
class Book < ActiveRecord::Base
searchkick
end
Then i run the command
Book.reindex
I get the following error
2.3.4 :001 > Book.reindex
Faraday::ConnectionFailed: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:878:in `connect'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from /usr/local/rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:852:in `start'
It makes sense because it is assuming the elastic search server is running on the default 9200 but i ran it on 8081. How do i tell searchkick gem to connect to 8081 port instead of 9200? I appreciate any help! Thanks!
Create an initializer config/initializers/elasticsearch.rb:
ENV['ELASTICSEARCH_URL'] = 'http://localhost:8081'
More in official doc
I an trying to open my root page it shows error "Internal server error"
=> Booting Thin
=> Rails 4.2.6 application starting in development on http://localhost:4000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on localhost:4000, CTRL+C to stop
DEPRECATION WARNING: You didn't set secret_key_base. Read the upgrade documentation to learn more about this new config option. (called from require at /home/smk/test/test/BMS-New/bin/rails:9)
Unexpected error while processing request: Missing secret_token and secret_key_base for 'development' environment, set these values in config/secrets.yml
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:534:in validate_secret_key_config!'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:246:inenv_config'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/engine.rb:514:in call'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/application.rb:165:incall'
/home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/content_length.rb:15:in call'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:86:inblock in pre_process'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:84:in catch'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:84:inpre_process'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:53:in process'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/connection.rb:39:inreceive_data'
/home/smk/test/test/BMS-New/vendor/bundle/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in run_machine'
/home/smk/test/test/BMS-New/vendor/bundle/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:inrun'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/backends/base.rb:73:in start'
/home/smk/test/test/BMS-New/vendor/bundle/gems/thin-1.6.4/lib/thin/server.rb:162:instart'
/home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in run'
/home/smk/test/test/BMS-New/vendor/bundle/gems/rack-1.6.4/lib/rack/server.rb:286:instart'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/server.rb:80:in start'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:inblock in server'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in tap'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:inserver'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in run_command!'
/home/smk/test/test/BMS-New/vendor/bundle/gems/railties-4.2.6/lib/rails/commands.rb:17:in'
/home/smk/test/test/BMS-New/bin/rails:9:in require'
/home/smk/test/test/BMS-New/bin/rails:9:in'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/rails.rb:28:in load'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/rails.rb:28:incall'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client/command.rb:7:in call'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/client.rb:30:inrun'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/bin/spring:49:in <top (required)>'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/binstub.rb:11:inload'
/home/smk/test/test/BMS-New/vendor/bundle/gems/spring-1.7.1/lib/spring/binstub.rb:11:in <top (required)>'
/usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
/usr/local/lib/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
/home/smk/test/test/BMS-New/bin/spring:13:in'
bin/rails:3:in load'
bin/rails:3:in'
In your config/secrets.yml file remove everything add this:
development:
secret_key_base: bcbfd4e5010b035e62898f964188362877783b43f94bf883cf4b1d82d9224349789fb9dd0c2f33a200acfa266024a285e324caa3b20d0a9a352014156e47ec5c
test:
secret_key_base: af068d8662bf954a2afeb27c64bbcdeb56b730029272bd3daff7e00c3c076999b3d2297747a3cef0550d3efd5cf8072e0477b8a62f096c94ab124f0d99320d20
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Your error refers that in your secrets.yml file secret_key_base and secret_token is missing.
FYI: You can change the secret_key_base as you like. If you don't have this file then create one. For different environment the secret_key_base will be different. You should add the environment there also. Here, I give key base for development/production/test environment
I have been using watir-webdriver / MiniTest framework for just under a month now and it has been going really well. However the pack that I'm required to run every time a new build is launched contains just under 100 individual tests which takes well over an hour to go through all of them.
This is why I setup a VPS with Ruby, RVM, Watir, Rails and Firefox on a Centos-6-x86_64. This way I don't have to run the scripts on my laptop and wait for them to finish before I can do anything else.
However when I tried to test that watir was working using irb I get the following error:
Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
Test:
[root#V-9876 ~]# irb
1.9.3p448 :001 > require 'watir-webdriver'
=> true
1.9.3p448 :002 > b = Watir::Browser.start 'www.google.com'
Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:28:in `initialize'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:28:in `new'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:28:in `block in free?'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:26:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:26:in `free?'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/port_prober.rb:5:in `above'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/firefox/launcher.rb:49:in `find_free_port'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/firefox/launcher.rb:33:in `block in launch'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/driver.rb:31:in `new'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver/common/driver.rb:31:in `for'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/selenium-webdriver-2.37.0/ lib/selenium/webdriver.rb:67:in `for'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir- webdriver/browser.rb:46:in `initialize'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir- webdriver/browser.rb:29:in `new'
from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/watir-webdriver-0.6.4/lib/ watir- webdriver/browser.rb:29:in `start'
from (irb):2
from /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/irb:13:in `<main>'1.9.3p4 1.9.3p448 :003 >
I have been researching that error and I have found many sites that claim that it is fixed by disabling ipv6 which I did and I am still getting this error.
Not sure if this makes a difference but I also have NGinX / PHP / MySQL installed on this VPS
EDIT - The ruby file is posted below
require "watir-webdriver"
require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
browser = Watir::Browser.new :ff
browser.goto "http://remove-url-for-this-post.com"
puts ("Starting SearchValSelectFields")
browser.select_list(:id, "edit-select-sector").select("Finance and Accounting")
sleep (5)
browser.select_list(:id, "edit-select-subsector--3").select("All Sub-sector")
browser.select_list(:id, "edit-select-location").select("Singapore")
browser.button(:value,"Search").click
assert(browser.text.include?("Salary and employment forecast"))
browser.screenshots ('..\screenshots\SearchValSelectFields.png')
browser.select_list(:id, "edit-select-sector").select("Select Sector")
sleep(3)
browser.select_list(:id, "edit-select-subsector--2").select("Select Sub-sector")
sleep(3)
browser.select_list(:id, "edit-select-location").select("Select Location")
sleep(3)
browser.button(:value,"Search").click
assert(browser.text.include?("This field is required"))
browser.close
headless.destroy
Any ideas?
Somebody at work managed to fix the issue. He said:
They try to connect twice
first to 127.0.0.1 port 7055
then too ::1 port 7055
second one fails
::1 is localhost of IPv6
so you seem to be connecting localhost
and in your server look at /etc/hosts
localhost resolves to the ::1
So all you have to do is edit your /etc/hosts file and comment out ::1 or remove it if you want
I keep getting this error when i try to run my localhost using "$rails s":
(Mac OSX 10.8.3)
(ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0])
(Rails 3.2.11)
(psql (PostgreSQL) 9.2.2 ) **installed with homebrew
I have been doing a lot of uninstalling postgresql and reinstalling so I have a hunch that there may be conflicting libraries somewhere...i just dont know where to start.
I had Postgresql 9.1 and 9.2 in the same folder and just moved 9.1 into the trash.
Here is the output when I run "rails s" in the terminal
Danny$ rails s
^[b=> Booting Thin
=> Rails 3.2.11 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize': could not connect to server: Connection refused (PGError)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5433?
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /Users/Danny/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /Users/Danny/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/model_schema.rb:308:in `clear_cache!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.11/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418:in `_run__3642716200177086041__prepare__4186317719333288752__callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Danny/Dropbox/programming/coding/f_app/config/environment.rb:7:in `<top (required)>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:3:in `block in <main>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:in `new'
from /Users/Danny/Dropbox/programming/coding/f_app/config.ru:in `<main>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands/server.rb:46:in `app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands/server.rb:70:in `start'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
from /Users/Danny/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
The error message is instrumental:
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5433?
port
You may be trying to connect to the wrong port.
Standard port is 5432. Check how (and whether at all) you started your postgres server:
postgres#db:~$ ps -auxww | grep ^postgres
... <stripped more lines>
postgres 1274 0.0 0.3 1437240 57308 ? S May27 5:01 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
The manual has related information here.
In my example, settings from /etc/postgresql/9.1/main/postgresql.conf got used, which says (among many other settings):
port = 5432
Or run:
netstat -nlp | grep postgres
Or just look here (at least in Debian or Ubuntu):
ls -lA /var/run/postgresql/
PostgreSQL picks the next free port if you create a new database cluster. Since you installed repeatedly, you may have confused port numbers.
listen_addresses
Or you just forgot to allow TCP/IP connections. Related answers:
Run batch file with psql command without password
What's the difference between "local" and "localhost" connection types in pg_hba.conf?
no pg_hba.conf entry for host
This may resolve the issue :-
Get the hba.conf file address by using command SHOW config_file; and SHOW hba_file; in sql prompt
Now open hba.conf and add this host all all 0.0.0.0/0 trust
Now open postgresql.conf and add listen_address = '*'
In my case, the problem was caused by the upgrade of postgresql-9.4 to postgresql-9.5 in Ubuntu 16.04. Since, There were two versions installed at some point in time, the later installed version i.e. postgresql-9.5's config changed to default port of 5433 (instead of standard default 5432).
The problem occurred when my Rails project tried to connect to the default port of postgresql (since the port was not defined explicitly defined in database.yml file) and kept failing. Even after removal of postgresql-9.4 later.
Solution changing postgresql's config file
The solution is changing the port in the configuration of updated postgresql (9.5). To do this open the file /etc/postgresql/9.5/main/postgresql.conf and change the line
port = 5433 # (change requires restart)
to
port = 5432 # (change requires restart)
and then restart the server with sudo service postgresql restart.
Solution with changing Rails' `database.yml' file
Alternatively, you can change rails' database.yml file by explicitly mention the new port (that ie 5433) without changing the postgresql's config file. To do this, simply add a line like this
port: 5433
and restart the rails server.
sudo -u postgres pg_ctlcluster 9.3 main stop
followed by
sudo -u postgres pg_ctlcluster 9.3 main restart
worked for me
I got this error message hooking up to Jira (from the Jira side) and the solution was to change the "Hostname or IP address of the database server." to "localhost". If you're running locally you can't just put in your local ip address.
Also the next issue for a local install is the password always fails even though that's correct because pg_hba.conf needs to be edited so the authentication method is "trust".
In postgresql.conf, /var/lib/pgsql/data/postgresql.conf :
change the listen_addresses = 'localhost' to listen_addresses = '*'
enable the default port as 5432, port = 5432
Also in pg_hba.conf, /var/lib/pgsql/data/pg_hba.conf,
try the authentication method as trust
I've used this site a bunch over the past three years or so...this is my first post :D
But enough of the useless banter and on to the business at hand.
I will start with the approach/problem, the error, and then a trace/log of the error.
Then I will go over what I've done so far to best this problem, some odd things I've noticed, and what I think might be causing it.
APPROACH/PROBLEM:
I was recently added to the back-end development team for a mobile app, and before I implement any new features I have to get the product up and running on my local machine...
(in app directory) rails s
=> Booting WEBrick
=> Rails 3.1.0.rc4 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-09-14 19:11:59] INFO WEBrick 1.3.1
[2011-09-14 19:11:59] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2011-09-14 19:11:59] INFO WEBrick::HTTPServer#start: pid=35031 port=3000
So all of this looks fine for now, but when I attempt to access the page on a browser...
ERROR:
(browser page title): Action Controller:Exception caught
PGError
fe_sendauth: no password supplied
TRACE/LOG
(continued from last line on terminal in the first section)
cache error: No server available
/Library/Ruby/Gems/1.8/gems/dalli-1.0.5/lib/dalli/ring.rb:45:in `server_for_key'
/Library/Ruby/Gems/1.8/gems/dalli-1.0.5/lib/dalli/client.rb:239:in `perform'
/Library/Ruby/Gems/1.8/gems/dalli-1.0.5/lib/dalli/client.rb:60:in `get'
/Library/Ruby/Gems/1.8/gems/rack-cache-1.0.3/lib/rack/cache/metastore.rb:320:in `read'
/Library/Ruby/Gems/1.8/gems/rack-cache-1.0.3/lib/rack/cache/metastore.rb:30:in `lookup'
/Library/Ruby/Gems/1.8/gems/rack-cache-1.0.3/lib/rack/cache/context.rb:165:in `lookup'
/Library/Ruby/Gems/1.8/gems/rack-cache-1.0.3/lib/rack/cache/context.rb:65:in `call!'
/Library/Ruby/Gems/1.8/gems/rack-cache-1.0.3/lib/rack/cache/context.rb:50:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.3.2/lib/rack/deflater.rb:13:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/rack/content_length.rb:16:in `call'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/rack/log_tailer.rb:14:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.3.2/lib/rack/handler/webrick.rb:59:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Library/Ruby/Gems/1.8/gems/rack-1.3.2/lib/rack/handler/webrick.rb:13:in `run'
/Library/Ruby/Gems/1.8/gems/rack-1.3.2/lib/rack/server.rb:265:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:70:in `start'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:54
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in `tap'
/Library/Ruby/Gems/1.8/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49
script/rails:6:in `require'
script/rails:6
cache: [GET /] pass
Dalli::Server#connect localhost:11211
localhost:11211 failed (count: 0)
I can give out the full trace from the browser as well, but I don't want this post to get TOO wordy.
So this is the dilemma!
What I've Done:
The simple solutions(listed below) haven't made any difference.
The pg gem installed correctly(after including the path manually)
I fixed the pg_hba.conf file to allow trust(ed) connections.
I can connect to a postgres db through the pgadmin3 tool and through the terminal.
Huh?:
Running the server on a different port doesn't make any difference, although if I try to connect to one of the ports reserved for my postgresql db, the connection is busy(I can post that error log as well, if needed).
If I try to access a non-existent page from the app...like users/explode or signin/signout, the error is the same. The terminal log does show the " [GET /'var'] pass " each time, though.
Thoughts:
My best guess is that the problem is from the connection still expecting a password, since there is a pass - word at the end of " [GET /'var'] pass "
OR
That the pg db is being run on a different server and the app doesn't like me trying to run it on my local machine.
I'm hoping your guess is better than mine.
If you managed to make it though this post, kudos. It's greatly appreciated.
If you manage to come up with a solution, somehow, I will be eternally gracious.
Regards,
~Ryan Johnson(RyeGuyHead)
Either change your pg_hba.conf to
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
Or replace trust to md5 and specify the password in database.yml