--- database.pgsql.inc.orig	2009-06-09 12:53:52.000000000 +0200
+++ database.pgsql.inc	2009-08-31 20:28:02.000000000 +0200
@@ -60,15 +60,20 @@
   if (isset($url['pass'])) {
     $conn_string .= ' password='. urldecode($url['pass']);
   }
-  if (isset($url['host'])) {
+  if ($url['host'] == "localhost") {
+    if (isset($url['port'])) {
+      $conn_string .= ' host='. urldecode($url['host']). ' port='. urldecode($url['port']);
+    }
+  } else {
     $conn_string .= ' host='. urldecode($url['host']);
+    if (isset($url['port'])) {
+      $conn_string .= ' port='. urldecode($url['port']);
+    }
   }
   if (isset($url['path'])) {
     $conn_string .= ' dbname='. substr(urldecode($url['path']), 1);
   }
-  if (isset($url['port'])) {
-    $conn_string .= ' port='. urldecode($url['port']);
-  }
+
 
   // pg_last_error() does not return a useful error message for database
   // connection errors. We must turn on error tracking to get at a good error
