基本 Postgres 和 MassiveJS 的连接终止
Connection terminated for basic Postgres and MassiveJS
我正在尝试连接到我的数据库,但我 运行 遇到了一些错误。我对这一切都很陌生,如果我不清楚,我很抱歉。我可以使用 pgAdmin 运行 查询我的数据库,但我似乎无法让它在这里工作。
这是我的错误:
/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:46
throw err;
^
Error: Connection terminated
at Connection.<anonymous> (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/pg/lib/client.js:183:17)
at Object.onceWrapper (events.js:290:19)
at emitNone (events.js:86:13)
at Connection.emit (events.js:185:7)
at Socket.<anonymous> (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/pg/lib/connection.js:66:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:501:12)
at Function.module.exports.loopWhile (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:72:22)
at Object.connectSync (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:44:19)
这是我的 server.js:
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var massive = require('massive');
var app = express();
app.use(bodyParser.json());
var port = 3000;
var conn = massive.connectSync({
connectionString : "postgres://postgres@localhost/massive_demo"
});
app.set('db', conn);
var db = app.get('db');
app.get('/incidents', function(req, res) {
console.log('POST sighting');
});
app.post('/incidents', function(req, res) {
console.log('POST sighting');
});
app.listen(port, function() {
console.log("Started server on port", port);
});
真的不知道还能说什么;我会尽力澄清任何不清楚的地方。
发现我的问题;显然更改 Postgres 中的端口影响了我的连接能力?不知道为什么,但将其改回默认的 5432 有效。
我正在尝试连接到我的数据库,但我 运行 遇到了一些错误。我对这一切都很陌生,如果我不清楚,我很抱歉。我可以使用 pgAdmin 运行 查询我的数据库,但我似乎无法让它在这里工作。
这是我的错误:
/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:46
throw err;
^
Error: Connection terminated
at Connection.<anonymous> (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/pg/lib/client.js:183:17)
at Object.onceWrapper (events.js:290:19)
at emitNone (events.js:86:13)
at Connection.emit (events.js:185:7)
at Socket.<anonymous> (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/pg/lib/connection.js:66:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:501:12)
at Function.module.exports.loopWhile (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:72:22)
at Object.connectSync (/Users/patrickholley/Desktop/Dockbox/Dev-Mtn/w6/d3/massive-demo/node_modules/deasync/index.js:44:19)
这是我的 server.js:
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var massive = require('massive');
var app = express();
app.use(bodyParser.json());
var port = 3000;
var conn = massive.connectSync({
connectionString : "postgres://postgres@localhost/massive_demo"
});
app.set('db', conn);
var db = app.get('db');
app.get('/incidents', function(req, res) {
console.log('POST sighting');
});
app.post('/incidents', function(req, res) {
console.log('POST sighting');
});
app.listen(port, function() {
console.log("Started server on port", port);
});
真的不知道还能说什么;我会尽力澄清任何不清楚的地方。
发现我的问题;显然更改 Postgres 中的端口影响了我的连接能力?不知道为什么,但将其改回默认的 5432 有效。