I recently switched from MySQL to postgres as my database for the node.js. project Although I can access my remote postgres database from my local pgAdmin III (OSX) client, so far I have not been able to connect to my database through node.js. I am sure that the credentials entered for pgAdmin and my node.js were exactly the same. Another thing I tried was that my local ipadress trusted instead of md5 in pg_hba.conf on my database server. Am I doing something wrong? My favorite search engine came up with some disturbing hits about rebooting my local OS. I just used the example from the github repo node-postgres document:
var pg = require('pg'); var conString = "postgres://myusername: mypassword@hostname :5432/dbname"; var client = new pg.Client(conString); client.connect(function(err) { if(err) { return console.error('could not connect to postgres', err); } client.query('SELECT NOW() AS "theTime"', function(err, result) { if(err) { return console.error('error running query', err); } console.log(result.rows[0].theTime); client.end(); }); });
And these are the errors that I get every time I try to start my server:
could not connect to postgres { [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
Help will be greatly appreciated
source share