title: node-postgres get error connect ECONNREFUSED
body: <p>I want to connect my apps nodejs using <a href="https://github.com/brianc/node-postgres" rel="noreferrer">node-posgres</a> to PostgreSQL.
  My apps in localhost (ubuntu) and my postgresql in virtual machine in the cloud with operating system OpenSuse.
  This is my code :</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  
  var http = require('http');
  var pg = require('pg');
  
  var conString = "postgres://postgres:mypassword@myurl.com:5432/postgres";
  
  
  app.get('/', function (req, res) {
      res.send('HOLAAAA');
  });
  
  // respond with "SERVER" on the homepage
  app.get('/server', function (req, res) {
  
      var client = new pg.Client(conString);
      client.connect(function (err) {
          if (err) {
              return console.error('could not connect to postgres', err);
          }
          console.log('CONNECT PASSED');
          client.query('SELECT * FROM visit', function (err, result) {
              if (err) {
                  return console.error('error running query', err);
              }
              console.log('QUERY PASSED');
              console.log(result.rows[0].theTime);
              //output: Tue Jan 15 2013 19:12:47 GMT-600 (CST)
              client.end();
          });
      });
  
  });
  
  
  var server = app.listen(3000, function () {
  
      var host = server.address().address;
      var port = server.address().port;
  
      console.log('Example app listening at http://%s:%s', host, port);
  
  });
  </code></pre>
  
  <p>But i got an error like this:</p>
  
  <pre><code>could not connect to postgres { [Error: connect ECONNREFUSED]
    code: 'ECONNREFUSED',
    errno: 'ECONNREFUSED',
    syscall: 'connect' }
  </code></pre>
  
  <p>Please help me how to solve this.
  Thanks!</p>