node.js postgres连接问题

我试图从node.js连接到postgres数据库,但我总是得到一些奇怪的错误

ENOTFOUND, Domain name not found 

我使用的node.js模块是'pg'。

在几个例子中我看到了不同的连接string

 pg://, tcp:// and postgres:// 

你能告诉我哪一个是正确的吗? 什么会导致这个问题?

这里是我用来尝试给我的PG数据库一个Web界面的一些代码。 它可以连接和插入/删除/selectlogging,具体取决于您通过curl或Web浏览器发送的命令。

 var app = require('express').createServer(); var pg = require('pg'); var conString = "postgres://YOURUSER:YOURPASSWORD@localhost/dev"; var client = new pg.Client(conString); client.connect(); app.get('/', function(req, res){ res.send('hello world'); }); app.get('/select/:client_id', function(req, res){ var query = client.query("select '{count:}' as c_count,client_id from test_input where client_id = $1 limit 1", [req.params.client_id]); query.on('row', function(row) { res.send(row); }); } ); app.get('/insert/:client_id', function(req, res) { console.log('called'); client.query("INSERT INTO test_input(client_id) VALUES($1)",[req.params.client_id]); res.send('done'); }); process.on('uncaughtException', function (err) { console.log(err); }); app.get('/delete/:client_id', function(req, res) { console.log('called'); client.query("DELETE FROM test_input WHERE client_id = $1",[req.params.client_id]); res.send('done'); });