title: connect ElephantSQL with node.js
body: <p>I am new to programming I tried to Use <a href="https://www.elephantsql.com/docs/nodejs.html" rel="nofollow noreferrer">ElephantSql</a>  postgres database server in node..but its not connecting..(i used the same code from doumentation.)</p>
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const cors = require('cors');
  const PORT = process.env.PORT || 3001;
  
  const app = express();
  
  app.use(cors())
  app.use(bodyParser.json());
  
  
  var pg = require('pg');
  var client = new pg.Client(&quot;postgres:/.elephantsql.com:The Actual url&quot;);
  
  client.connect(function(err) {
    if(err) {
      return console.error('could not connect to postgres', err);
    }
    client.query('SELECT NOW() AS &quot;theTime&quot;', function(err, result) {
      if(err) {
        return console.error('error running query', err);
      }
      console.log(result.rows[0].theTime);
      // &gt;&gt; output: 2018-08-23T14:02:57.117Z
      client.end();
    });
  
  });
  
  app.get('/', (req, res) =&gt; { res.send('its working') })
  
  app.listen(PORT, () =&gt; {
    console.log(`app is running on PORT:${PORT}`);
  })
  </code></pre>