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
Related
Most of what I've seen revolve around sudo service postgresql restart
Tried that and no avail.
Other answers I've seen are removing a file from /usr/local/var/psql
Issue with that is I do not have a /var/ folder in /local/
Full dump:
[17:51:55] shell-ratings-backend (master)
// ♥ sudo service postgresql restart
* Restarting PostgreSQL 14 database server [ OK ]
[17:52:29] shell-ratings-backend (master)
// ♥ rails db:migrate
rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/rails:5:in `<top (required)>'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:10:in `require'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:10:in `block in <top (required)>'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:7:in `tap'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:7:in `<top (required)>'
Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/rails:5:in `<top (required)>'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:10:in `require'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:10:in `block in <top (required)>'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:7:in `tap'
/mnt/c/Users/Alex/dev/shell-ratings-backend/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The error states that the psql utility can't find the socket to connect to your database server. Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed.
Step 1: Verify that the database is running
The command may vary depending on your operating system. But on most *ix systems the following would work, it will search for postgres among all running processes
ps -ef | grep postgres
You can look at all the options available to start the postgres server using the following.
man postgres From there, you'd see that the options -D and -r are respectively the datadir & the logfilename.
Step 2: If the postgres service is running
Use find to search for the location of the socket, which should be somewhere in the /tmp
sudo find /tmp/ -name .s.PGSQL.5432
If postgres is running and accepting socket connections, the above should tell you the location of the socket. On my machine, it turned out to be:
/tmp/.s.PGSQL.5432
Then, try connecting via psql using this file's location explicitly, eg.
psql -h /tmp/ dbname
Step 3: If the service is running but you don't see a socket
If you can't find the socket, but see that the service is running, Verify that the pg_hba.conf file allows local sockets.
Browse to the datadir and you should find the pg_hba.conf file.
By default, near the bottom of the file you should see the following lines:
"local" is for Unix domain socket connections only
local all all trust
If you don't see it, you can modify the file, and restart the postgres service.
When I attempt to start my rails server from my local machine, I get the following error message.
/Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:269:in `initialize': Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:269:in `new'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:269:in `add_tcp_listener'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:105:in `block in parse'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:88:in `each'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/binder.rb:88:in `parse'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/runner.rb:144:in `load_and_bind'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/cluster.rb:391:in `run'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/puma/launcher.rb:174:in `run'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/puma-3.9.1/lib/rack/handler/puma.rb:69:in `run'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/server.rb:297:in `start'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands/server.rb:104:in `start'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:85:in `server'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.3/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/zachdobbs/sample_app/bin/rails:9:in `require'
from /Users/zachdobbs/sample_app/bin/rails:9:in `<top (required)>'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/zachdobbs/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/zachdobbs/sample_app/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
This error occurred suddenly and I'm not sure what the cause of it could be. When I looked online I noticed that the issue could be another service running on the port 3000, but when I try and run 'lsof -i tcp:3000' I get no results.
Within puma.rb, I define.
port ENV.fetch("PORT") { 3000 }
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
When I change the port value to something such as 8080 the server will run. I am confused as to why the server will not launch on port 3000. Every command I have attempted to run has shown me no services running on that port.
I know this is a really old post but I had to answer just in case others get here as I did.
When you declare port or bind commands in the puma config it will try to bind to all those ports or addresses.
In this case you've specified port twice so it's trying to bind to both and the second one will fail.
Try the following:
> sudo ps ax | grep rails
#1338 pts/1 Sl+ 0:06 /usr/bin/ruby2.3 bin/rails c
#1707 pts/0 Rl+ 0:07 /usr/bin/ruby2.3 bin/rails s
> sudo kill -9 1707
> rails s
For me, the solution was pretty easy. But please be aware that (as the command says) shuts down ALL instances of ruby. You could solve it more fine-grained than this, e.g. with a strategy like Abhi mentioned.
killall ruby
All other things didn't help me:
killall rails
# -> rails: no process found
killall puma
# -> puma: no process found
You can also consider these possibly related Q/A:
Address already in use - bind(2) for "0.0.0.0" port 3000 (Errno::EADDRINUSE)
Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)
jekyll 2.2.0 | Error: Address already in use - bind(2)
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 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.