Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:26:04+00:00 2026-06-17T14:26:04+00:00

I have a problem with the connection database MongoDB in Cloud9 Please help to

  • 0

I have a problem with the connection database MongoDB in Cloud9
Please help to resolve this issue!

var MongoClient = require("mongodb").MongoClient;
var port = process.env.PORT;
var ip   = process.env.IP;
MongoClient.connect("mongodb://"+ip+":"+port+"/test",function(error,db){
        if(!error){
         console.log("We are connected");   
        }
        else{
         console.dir(error); //failed to connect to [127.4.68.129:8080]               
        }
});

Output:

Running Node Process
Your code is running at 'http://demo-project.alfared1991.c9.io'.
Important: use 'process.env.PORT' as the port and 'process.env.IP' as the host in your scripts!
[Error: failed to connect to [127.4.68.129:8080]]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:26:05+00:00Added an answer on June 17, 2026 at 2:26 pm

    process.env.PORT and process.env.IP are the port and IP address for your application, not your database. You’ll want to pull your Mongo connection string from your MongoDB provider.

    Below is the hello world example from the Node.js homepage modified to use the two environment variables.

    var http = require('http');
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello World\n');
    }).listen(process.env.PORT || 1337, process.env.IP || '127.0.0.1');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem involves checking if I have a valid database connection before reading from
I have been having a problem where after my mongodb connection to mongohq via
I have a severe problem with my database connection in my web application. Since
I have a problem in WSO2 DSS, the database connection timeout is occurring after
i have problem with connection.. I can connect without problems to my database, when
I have a problem on linking files such as stylesheets, images, database connection file(db.php),
I have to solve problem with the database connection. I checked the ip address
I have this problem with c3p0 connection pooling, i am new with c3p0. My
I'have some problem to config cakephp database connection with appfog service. AppFog provides JSON
I have a strange problem on ipv6 connection. I write down a simple client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.