0

so I was working on a small node.js app and tried to host it on openshift. When I tried to do so and uploaded all of my files using git, It failed to connect to the port "8080". How can I stop this error? Here is my Java code:

var app = require('express')();
var http = require('http').Server(app);

var socket = io.connect('http://mattandjeffchat-appdevthing.rhcloud.com:8000/',{'forceNew':true });
http.listen(3000, function(){
 console.log('listening on *:3000');
 });
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

app.get('/', function(req, res){
 res.sendfile('index.html');
  });

io.on('connection', function(socket){
console.log('a user connected');
 });

Here is a picture of the error I get wont connect to 8080 server

Aero
  • 19
  • 7

1 Answers1

0

When deploying app's on production environments this is what is recommended as the port on environment you are deploying may not be openly available.

http.listen(process.env.PORT || 8080, "0.0.0.0", function () {
    console.log("App Started");
}); 
damitj07
  • 2,689
  • 1
  • 21
  • 40