org.postgresql.util.PSQLException: Connection refused

Hello,

I am deploying the Jruby application with Postgresql database on Tomcat
6.0.32. Jruby version is 1.5.1(ruby 1.8.7 patchlevel 249). I have
unpacked the gems into the vendor/gems directory and also freezed the
rails into vendor/rails directory. Then I created the war file using
warble. The war file is copied into the tomcat webapps folder.

There was an initial error with the activerecord-jdbcpostgresql-adapter
gem when it is unpacked into the vendor/gems folder. The unpacked gem
folder name was activerecord-jdbcpostgresql-adapter-1.0.2-java. The
error was because of the string java attached at the end of the folder
name. After I did some google, found out that the string “-java” was
causing the error and renamed the folder name and removed the string
“-java”. Now I am getting connection refused error when I look into the
log file.

Here is the error log

31 Mar, 2011 4:07:01 PM org.apache.catalina.core.ApplicationContext log
INFO: /!\ FAILSAFE /!\ Thu Mar 31 16:07:01 +0530 2011
Status: 500 Internal Server Error
The driver encountered an unknown error:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/connection.rb:93:in
initialize' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/adapter.rb:31:innew’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/adapter.rb:31:in
initialize' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/connection_methods.rb:6:innew’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/connection_methods.rb:6:in
jdbc_connection' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/postgresql/connection_methods.rb:13:inpostgresql_connection’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
new_connection' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:incheckout_new_connection’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in
checkout' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:inloop’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
checkout' file:/usr/local/tomcat/webapps/Control/WEB-INF/lib/jruby-stdlib-1.5.1.jar!/META-INF/jruby.home/lib/ruby/1.8/monitor.rb:191:inmon_synchronize’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in
checkout' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:inconnection’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:inretrieve_connection’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in
connection' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:incache’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in
call' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:incall’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in
call' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/rack-1.1.0/lib/rack/head.rb:9:incall’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in
call' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:incall’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:99:in
call' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:incall’
/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/rack-1.1.0/lib/rack/lock.rb:11:in
call' /usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:incall’
file:/usr/local/tomcat/webapps/Control/WEB-INF/lib/jruby-rack-1.0.2.jar!/rack/adapter/rails.rb:36:in
serve_rails' file:/usr/local/tomcat/webapps/Control/WEB-INF/lib/jruby-rack-1.0.2.jar!/rack/adapter/rails.rb:41:incall’
file:/usr/local/tomcat/webapps/Control/WEB-INF/lib/jruby-rack-1.0.2.jar!/jruby/rack/rails.rb:180:in
call' file:/usr/local/tomcat/webapps/Control/WEB-INF/lib/jruby-rack-1.0.2.jar!/rack/handler/servlet.rb:19:incall’
:2

I even checked the pg_conf.hba file and it has the below conf.
TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 192.168.0.0/24 password

Any help would be appreciated.

Regards,
Madhusudhan.

That is probably one for the postgres list. It is likely your postgres
installation hasn’t been configured to listen for TCP connections, or
you’ve misconfigured your jdbc connection parameters.

On Thu, 2011-03-31 at 12:51 +0200, Madhusudhan H R wrote:

folder name was activerecord-jdbcpostgresql-adapter-1.0.2-java. The
Status: 500 Internal Server Error

/usr/local/tomcat/webapps/Control/WEB-INF/vendor/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/connection_methods.rb:6:in

`checkout’

/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in

`call’

/usr/local/tomcat/webapps/Control/WEB-INF/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in

`call’
Any help would be appreciated.

Regards,
Madhusudhan.


Nick G.
Developer @ Media Service Provider
+44 207 729 4797

On Thu, Mar 31, 2011 at 5:11 PM, Nick G. [email protected]
wrote:

That is probably one for the postgres list. It is likely your postgres
installation hasn’t been configured to listen for TCP connections, or
you’ve misconfigured your jdbc connection parameters.

Yep, that’s very likely since the default configuration of postgres
does not listen on public IP addresses of the machine. Docs are here:

Cheers

robert


remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/