部署到Heroku时无法连接到mlab mongodb

时间:2018-01-29 18:11:20

标签: node.js mongodb heroku mlab

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
mongoose.Promise = global.Promise;

console.log('In App file');
 var url=  

'mongodb://<user_name>:password>@ds119088.mlab.com:19088/pnk_employees';

mongoose.connect(url)
  .then(() =>  console.log('connection succesful'))
  .catch((err) => console.error(err));

当我在Heroku控制台上运行我的应用程序时,出现以下错误:'MongoError:第一次连接时无法连接到服务器[gmail.com:27017]。

如何解决此问题?

0 个答案:

没有答案