1

i have written a simple hello world program in express node.js and when i call it through Curl it's response is correct i.e it displays Hello world on the console but when i call the url from browser i get could not connect error.Here is my code:

/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

var app = express();

// all environments
app.set('port', process.env.PORT || 3039);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);
app.get('/partner', function(req, res){

    res.send('Hello World');
});
http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});
2
  • what page did you open in the browser? Commented May 29, 2013 at 9:21
  • test.com:3039/partner is the url and server file name is app.js Commented May 29, 2013 at 10:32

2 Answers 2

1

You have either a DNS issue or a Firewall issue.

Perhaps this answer will help you.

Sign up to request clarification or add additional context in comments.

3 Comments

The problem is that it works fine on localhost and also when i call the url through curl its response is fine but when i call in browser it shows cannot connect.I don't know what can be the possible reason.
@user2431743 is your browser configured to use a proxy server?
Check "netstat -na" and make sure that the listener is on 0.0.0.0 rather than 127.0.0.1
0

Which cloud service you are using for node.js .share url of this page

3 Comments

The clould service is UKFast and operating system is centos.
did you check it on window azzure ? . share the url
I have this node.js app on window azzure cloud service blueapplesite.cloudapp.net

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.