dmanjunath/node-redshift

Issue with connecting to my database.

Closed this issue · 2 comments

Please help ! I have redshift cluster and from sql workbench everything works fine, i can connect and work. I tried to connect to my database from node.js server. i installed this module, tried to use, but every time i was getting

error: getaddrinfo ENOTFOUND jdbc:.... (and my jdbc link)

i tried with both raw and normal connection

here is my sample code

const Redshift = require('node-redshift');
const redShiftConnectionOptions = {
    user: 'myusername',
    database: 'mydatabase',
    password: 'mypassword',
    port: 5439,
    host: 'jdbc:redshift://my-redshift-link'
  };

  const redshiftClient = new Redshift(redShiftConnectionOptions, {
    rawConnection: true
  });

redshiftClient.connect(function(err) {
    if (err) {
      console.log('error is here');
      throw err;
    } else {
      redshiftClient.query('select * from "photo_tags"', function(err, data) {
        if (err) throw err;
        else {
          res.send(data);
          redshiftClient.close();
        }
      });
    }
  });

Every time it goes to connection error.

Hi,
Did you find the answer for this? I am also getting the same error. Can you please let us know whether it is because of the host name? or something else?

Thanks.

hey @Tomarr . i was passing wrong configuration object. in the example above host name is like
host: 'jdbc:redshift://my-redshift-link'
instead it should be

 host: encodeURI(
        'redshift-cluster-...........'
    )