PostgreSQL + Rails connection troubleshooting - ruby-on-rails

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

Related

Pry on the production server - how can I make it work there?

I can debug an app locally with binding.pry just fine. But I need to that on the remote server (webiste) as well, because locally I don't have any error but on production I do. So put binding.pry in the source file on the server and when I made a post request to the website, I didn't return any response and even when I ran rails console on the server didn't change anything and there was no output in rails console.
It's a dev server, so it's visible in the internet but it's a developer server, although for rails it's production because RAIL_ENV is equal to production. I really need to debug it the way I can do locally using pry. How can I do it?
update:
# bundle exec pry-remote
/usr/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open': druby://127.0.0.1:9876 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> (DRb::DRbConnError)
from /usr/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `each'
from /usr/lib/ruby/1.9.1/drb/drb.rb:729:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `new'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1171:in `open'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
from /usr/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/lib/pry-remote.rb:289:in `run'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/gems/pry-remote-0.1.8/bin/pry-remote:4:in `<top (required)>'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `load'
from /web/my_site.com/releases/201501271120/vendor/bundle/ruby/1.9.1/bin/pry-remote:19:in `<main>'
I assume your production app is run by some kind of daemonized application server, such as Puma or Unicorn.
In this setup, pry-remote can help.
add it to your Gemfile
use binding.remote_pry instead of binding.pry
execute bundle exec pry-remote on your server
You'll get a pry shell as soon as the breakpoint has been hit.

Connection refused (PGError) (postgresql and rails)

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

HTTPClient::ConnectTimeoutError while using 'fb_graph' gem

I have one rails project and two machinges. One is running Ubuntu 10.04 and the other 12.04 beta. I'm using the 'fb_graph' gem on the 10.04 machine all works fine, but when I do on the 12.04 machine things like
me = FbGraph::User.me(token).fetch
I get
HTTPClient::ConnectTimeoutError: execution expired
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `ssl_connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:739:in `block in connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:731:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:594:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:161:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:1060:in `do_get_block'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:869:in `block in do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:956:in `protect_keep_alive_disconnected'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:868:in `do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:756:in `request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:661:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:49:in `block in get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:122:in `handle_response'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:48:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:18:in `fetch'
from (irb):10
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have no idea why this happen nor how I could solve it. Any ideas? Thanks!
Jan
Reasons it could be happening are hardware performance of the machine, and network performance.
Try it again a couple times. Sometimes the network needs time to load routing information, but once it's loaded it goes faster the next times. That may not be a good production solution, but it could diagnose if the problem is freshening the network routing.
This could be a true network performance issue. That might not help you, if you cannot tune your network.
If re-trying helps, you could put a re-try loop around your code.
(0..2).each do
begin
... #your code goes here
break
rescue HTTPClient::ConnectTimeoutError
end
end
The HTTP request is timing out between the server and FB. See this github issue for an explanation of how to configure the HTTP client's timeout option.

No Route matches "say/hello" when route exists

I'm trying to create a very simple Hello, world program in RoR, but when I go to view the url http://localhost:3000/say/hello I'm getting the error message No route matches: "say/hello"
When I started the rails server I got this message with warnings scattered throughout:
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-06-20 20:02:44] INFO WEBrick 1.3.1
[2011-06-20 20:02:44] INFO ruby 1.9.2 (2011-02-18) [i686-linux]
[2011-06-20 20:02:44] WARN TCPServer Error: Address already in use - bind(2)
Exiting
/home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `new'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `block in create_listeners'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in `each'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in `create_listeners'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:74:in `listen'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:62:in `initialize'
from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:24:in `initialize'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/handler/webrick.rb:10:in `new'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/handler/webrick.rb:10:in `run'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/server.rb:217:in `start'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I started with: rails generate controller Say hello goodbye
which lists route get "say/hello"
Also: I'm having this problem which is probably related. When I go to write some basic html in one of the files that is clearly listed as existing I get this:
I write this:
~/work/demo$ /app/views/say/hello.html.erb
Get this error message in return:
bash: /app/views/say/hello.html.erb: No such file or directory
What's going on here? I'm getting these instructions straight from Agile Development with Rails and it's so simple. I don't understand what's going on.
[2011-06-20 20:02:44] WARN TCPServer Error: Address already in use - bind(2)
You already have a server (or something) running on the port your server is supposed to be running on. As such, the code you think is running (which you say has the route in question) actually isn't running. Once you shut down the other process (probably a previously running rails server?), you can start the correct one and make sure it actually has that route.
The error you're getting at rails startup indicates that there is already a server running at port 3000 on your machine (and apparently that server knows nothing of a "say/hello" route). Shut that one down and try again.
The second error is because from bash the path / goes to the root directory. Try:
cat app/views/say/hello.html.erb
I am faced with a similar problem. In my case after $ rails server command I am unable to shut down the server using ctrl-C in the terminal itself. Nothing happens when I press ctrl-C in the terminal.
When I reopen the project on another terminal, and run it again I get the following message:
System-Product-Name:~/testapp$ 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-06-30 16:41:23] INFO WEBrick 1.3.1
[2011-06-30 16:41:23] INFO ruby 1.9.2 (2011-02-18) [x86_64-linux]
[2011-06-30 16:41:23] WARN TCPServer Error: Address already in use - bind(2)
Exiting
/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
ls.rb:73:innew'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in block in create_listeners'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:ineach'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in create_listeners'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:74:inlisten'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:62:in initialize'
from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:24:ininitialize'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/rack-1.3.0/lib/rack/handler/webrick.rb:10:in new'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/rack-1.3.0/lib/rack/handler/webrick.rb:10:inrun'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/rack-1.3.0/lib/rack/server.rb:265:in start'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:70:instart'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:54:in block in <top (required)>'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:intap'
from bubble/.rvm/gems/ruby-1.9.2-p180#rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in <top (required)>'
from script/rails:6:inrequire'
from script/rails:6:in `'
In essence I have to kill the process from system monitor everytime. Can this be cured?
On a mac, type the following in your terminal:
lsof | grep IPv4
or
lsof|grep 3000 in linux i think.
find the lione that starts with 'ruby' and note the number next to that.
let's say the number is 1234. type the following in you terminal:
kill -9 1234
and you should be right. Remember to exit out of WEBrick with control-c!

Rails 3 Server crashes on start: "Not a socket file descriptor"

I'm trying to get started with Ruby on Rails, and it's all gone quite well up until I try to start the server. I get the following error:
C:\Users\Ken\workspace\railsHello>rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-03-10 19:53:08] INFO WEBrick 1.3.1
[2011-03-10 19:53:08] INFO ruby 1.9.2 (2011-02-18) [i386-mingw32]
[2011-03-10 19:53:09] WARN TCPServer Error: not a socket file descriptor
Exiting
C:/Ruby192/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': not a socket file
descriptor (ArgumentError)
from C:/Ruby192/lib/ruby/1.9.1/webrick/utils.rb:73:in `new'
from C:/Ruby192/lib/ruby/1.9.1/webrick/utils.rb:73:in `block in create_l
isteners'
from C:/Ruby192/lib/ruby/1.9.1/webrick/utils.rb:70:in `each'
from C:/Ruby192/lib/ruby/1.9.1/webrick/utils.rb:70:in `create_listeners'
from C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:74:in `listen'
from C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:62:in `initialize'
from C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:24:in `initialize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler/web
rick.rb:10:in `new'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/handler/web
rick.rb:10:in `run'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:2
13:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/comman
ds/server.rb:65:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/comman
ds.rb:30:in `block in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/comman
ds.rb:27:in `tap'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/comman
ds.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
C:\Users\Ken\workspace\railsHello>
I don't even know where to start with "TCPServer Error: Not a socket file descriptor."
Trying it through Aptana didn't help either.
I'm on Windows 7 Home Premium. Apache was already installed, but I shut it down and it didn't make a difference.
Thanks in advance for your help!
-Ken
Are you sure nothing else is listening on port 3000 (perhaps an old instance of the server that didn't get shut down)? Check the following:
netstat -a -b
If there is, simply kill that application, or start WEBrick on another port; for example, to start it on port 8000:
rails server --port=8000

Resources