MongoDB / Monk / NodeJS / LocalHost

nodejs
mongodb

#1

I’ve seen a lot of questions regarding localhost when using C9.

The tutorial i’m working on just has a few inserts saved in a mongodb and the .jade view will display the table inserts.

The tutorial says to add this code:

var mongo = require(‘mongodb’);
var monk = require(‘monk’);
var db = monk(‘localhost:27017/nodetest1’);

Do I just replace localhost with process.env.IP:27017 like this?:

var db = monk(‘process.env.IP:27017/nodetest1’);

I did this but am still having problems.

The userlist.jade file is very basic:

extends layout

block content
h1.
User List
ul
each user, i in userlist
li
a(href=“mailto:#{user.email}”) = user.username

When I start the application and attempt going to https://myapi-creativeplay.c9users.io/userlist, it takes a long time to load, and it just loads the following HTML:

Error 502 - Bad Gateway .error_content { background: rgba(255, 255, 255, 0.23); padding: 10px; width: 641px; margin: 25px 0; display: none; }
#error-msg {
    display: block;
}
</style>

Error 502 - Bad Gateway

Please click here to try again, if the issue persists please contact support

  <a href="http://status.c9.io">Status Page</a> |
  <a href="https://c9.io/support">Support</a> |
  <a href="https://c9.io/dashboard.html">Dashboard</a> |
  <a href="https://c9.io">Home</a>
</div>

Any help would be appreciated.