2017-03-01 15 views
0

私のデータベースに接続しようとしていますが、いくつかのエラーが発生しています。私はこのすべてにかなり新しいです、もし、私が明確でないなら、ごめんなさい。 pgAdminを使用してデータベースにクエリを実行することはできますが、ここでは機能しないようです。ここで基本的なPostgresとMassiveJSの接続が終了しました

は私のエラーです:

/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://[email protected]/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); 
}); 

は本当に言って他に何か分からないのです。どこにいてもわからないことを明確にするために最善を尽くします。

答えて

0

問題が見つかりました。明らかにPostgresのポートを変更することは私の接続能力に影響したのでしょうか?理由は分かりませんが、デフォルトの5432に戻して変更しました。

+0

接続文字列にPostgresがリッスンしているポートが指定されていないため、Massiveはデフォルトを想定しています。非標準のポートを使用したい場合は、 'postgres:// postgres @ localhost:5433/massive_demo'を含める必要があります。 – dmfay

+0

素晴らしい、洞察力がありがとう! –

関連する問題