nodejs和mongodb通过应用程序进行远程访问

时间:2016-02-21 08:39:26

标签: node.js mongodb backbone.js backbone-views backbone-routing

我使用nodejs和mongodb以及backbonejs进行了网络应用设置。

当我远程运行我的应用程序并尝试通过uri重定向到不同的路径时,例如:http://www.myapp.com/route我收到了网络错误。

在我的route.js文件中,我有以下内容:

  var mongodb = require('mongodb');
   var db = new mongodb.Db('dbname', new mongodb.Server('xx.xx.xxx.xxx', 27017, {}));

其中xx.xx.xxx.xxx是我的公共IP。但是,当我将此更改为" localhost"以外的任何内容时并尝试在我的应用程序的根目录中运行节点server.js我收到以下错误:

Listening on port 3000...

/var/www/html/pages/node_modules/mongodb/lib/server.js:236
        process.nextTick(function() { throw err; })
                                            ^
Error: connect ECONNREFUSED
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1012:19)

我已经在其他帖子中建议的/etc/mongod.conf文件中取消注释了bindIp。我这样做只是为了测试,只是为了让它工作,但我打算回去玩ip表,如果我让它工作。

如何远程访问我的应用程序?

0 个答案:

没有答案