0

I have looked through the forums to get help with the problem I am having. I get this error above and my app crashes on heroku. It seems to work fine locally. I read through the forums to see if there was a similar problem. Most people say that I have an issue with the local host and it should be set different. I am not sure what the write way to deploy this app should be and what I need to change. I tried to change the port. Or remove it and I was not able to do anything successfully. I have listed the server file below and followed heroku guidelines on their site. If I need to post more code I will but I am hoping someone could direct me. Thanks

    .then(db.exists)
    .then((isDbExists) => {
        if (config.demomode) {
            if (debugMode) {
                if (!isDbExists) {
                    require('./scripts/mongorestore');
                } else {
                    logger.debug('no database restore, it already exists');
                }
            } else {
                require('./scripts/mongorestore');
            }
        }
        const debug_http_port = 9091;
        const app_http_port = process.env.LOCA_NODEJS_PORT || process.env.PORT || 8080;
        const http_port = debugMode ? debug_http_port : app_http_port;
        app.listen(http_port, function() {
            logger.info('Listening port ' + http_port);
            if (!debugMode) {
                logger.info('In production mode');
            } else {
                logger.info('In development mode (no minify/no uglify)');
            }
            if (config.demomode) {
                logger.info('In demo mode (login disabled)');
            }
            const configdir = process.env.LOCA_CONFIG_DIR || process.env.CONFIG_DIR || path.join(__dirname, 'config');
            logger.debug('loaded configuration from', configdir);
            logger.debug(JSON.stringify(config, null, 1));
            if (debugMode) {
                const browserSync = require('browser-sync');
                browserSync.init({
                    proxy: `localhost:${debug_http_port}`,
                    files: ['dist'],
                    port: app_http_port,
                    weinre: {
                        port: 8080
                    },
                    open: false
                });
            }
        });
    })
    .catch((err) => {
        logger.error(err);
        process.exit(1);});```






xRose1
  • 25
  • 1
  • 6
  • did u let heroku assign the port : re : https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-of – Robert Rowntree Dec 11 '19 at 03:10
  • I have the file set as process.env.PORT || 8080? Does this not work – xRose1 Dec 11 '19 at 03:53
  • have you read "see using process.env.port" ?? https://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error – Robert Rowntree Dec 11 '19 at 18:08

0 Answers0