我试图连接到aws中的postgres数据库实例,但我不能

时间:2016-04-08 06:35:12

标签: database postgresql amazon-web-services

我有以下代码。

var express = require('express');
var app = express();
var path = require('path');
var pg = require('pg');


var conString = "postgres://user:password@endpoint:5432/StudentRecords";

//this initializes a connection pool 
//it will keep idle connections open for a (configurable) 30 seconds 
//and set a limit of 20 (also configurable) 
var client = new pg.Client(conString);
    client.connect(function(err) {
      if(err) {
        return console.error('could not connect to postgres', err);
      }
      else{
        console.log("asdfaf")
      }
      });
client.connect();

它显示无法连接到postgres。但是当我尝试使用

从终端连接时
psql    --host=endpoint    --port=5432    --username xxxxx    --password   --dbname=StudentRecords

我可以连接。为什么代码不起作用?我得到的错误是:

could not connect to postgres [Error: Connection terminated]

0 个答案:

没有答案
相关问题