Rails 4 ActiveRecord throws PG::UnableToSend on Ubuntu 13.04
activerecord, postgresql, ruby, ruby-on-rails, ubuntu
Solution
This basically happens when you use an old version of launchy , and as per this issue on launchy's git repo quoting @infertux
In the rare case when `exec` fails to run the command - typically when the file cannot be opened raising `Errno::ENOENT` - Launchy would raise an exception but not showing any output
You can check your `Gemfile.lock` to see if you're using a version of `launchy` below 2.4.1, and I doubt that you're using `letter_opener` Gem in your development environment which depends on `launchy` so updating `letter_opener` to 1.2.0 will update `launchy` to a version above 2.4.0 mostly 2.4.2 which has this issue fixed
All credit goes to @infertux
Problem
We have a `Ruby v.2.0.0-p247` on `Rails v4.0.1` application using `pg gem v0.17.0`. The application runs smoothly under `Mac OS X Mavericks v10.9` with `PostgreSQL Server v9.2.4` installed using `HomeBrew` but it throws the following exception under `Ubuntu v13.04` using `PostgreSQL Server 9.1`: `PG::UnableToSend: server closed the connection unexpectedly` `This probably means the server terminated abnormally before or while processing the request.` The exception occurs after transactional queries (form submission). I tried the following with `database.yml`: - Adding `reconnect: true` - Adding `port: 5432` - Adding `socket: /var/run/postgresq/SOCKET_FILE` And tried the following with PostgreSQL configuration under Ubuntu: - Disabling SSL. - Changing TCP keepalives parameters to pump timeout. - Changing log level to `DEBUG` and search for possible errors on PostgreSQL Server. Also tried: - Downgrade to pg gem v0.16.0. - Update all Ubuntu 13.04 packages to latest versions. What could possible be wrong? UPDATES: 12/03/2013: Some suggested checking firewall settings. `ufw status` said that `ufw` is disabled. 12/08/2013: After trying out with a vanilla Rails app and a lot of mangling with the current application, the problem is originating from `rails4/activerecord-session_store` gem. Line 47 in `lib/active_record/session_store/session.rb` is the culprit.