title: Postgresql Error: connection terminated
body: <p>i have a simple application linked up to a postgres database. it reads about 30 rows of data when you load up the application. but every now an then it wont load and when i look at my server i have the error Error: connection terminated.</p>
  
  <p>usually if i load it up several times in a short space of time.</p>
  
  <p>does anyone know why this might be happening? am i working it too hard?</p>
  
  <p>the code is below:</p>
  
  <pre><code>    function getDB(callback){
          console.log('inside getDB')
          Client.connect(function(err){
              if(err){
                  return console.log('connection error', err)
              }
              Client.query('SELECT * FROM gallery', function(err, result){
                  if(err){
                      return console.log('error receiving data', err)
                  } else{
                  callback(null, result.rows)
                  }
                  Client.end()
              })
  
          })
      }
  </code></pre>