Heroku Web process failed to bind to $PORT within 60 seconds of launch










1















i am making an application in angular, runs fine locally but when i try to deploy it with heroku, shows the next error:



 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 


the code looks like this:



const express= require('express'),
path= require('path');

const app =express();

app.use(express.static('./dist/re-mi'));

app.get('/*', (req,res)=>
res.sendFile(path.join(__dirname, '/dist/myapp/index.html'));
);

var port_number = server.listen(process.env.PORT || 3000);
app.listen(port_number);


i also see other questions with the same error but no answer works for me










share|improve this question


























    1















    i am making an application in angular, runs fine locally but when i try to deploy it with heroku, shows the next error:



     Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 


    the code looks like this:



    const express= require('express'),
    path= require('path');

    const app =express();

    app.use(express.static('./dist/re-mi'));

    app.get('/*', (req,res)=>
    res.sendFile(path.join(__dirname, '/dist/myapp/index.html'));
    );

    var port_number = server.listen(process.env.PORT || 3000);
    app.listen(port_number);


    i also see other questions with the same error but no answer works for me










    share|improve this question
























      1












      1








      1








      i am making an application in angular, runs fine locally but when i try to deploy it with heroku, shows the next error:



       Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 


      the code looks like this:



      const express= require('express'),
      path= require('path');

      const app =express();

      app.use(express.static('./dist/re-mi'));

      app.get('/*', (req,res)=>
      res.sendFile(path.join(__dirname, '/dist/myapp/index.html'));
      );

      var port_number = server.listen(process.env.PORT || 3000);
      app.listen(port_number);


      i also see other questions with the same error but no answer works for me










      share|improve this question














      i am making an application in angular, runs fine locally but when i try to deploy it with heroku, shows the next error:



       Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 


      the code looks like this:



      const express= require('express'),
      path= require('path');

      const app =express();

      app.use(express.static('./dist/re-mi'));

      app.get('/*', (req,res)=>
      res.sendFile(path.join(__dirname, '/dist/myapp/index.html'));
      );

      var port_number = server.listen(process.env.PORT || 3000);
      app.listen(port_number);


      i also see other questions with the same error but no answer works for me







      javascript heroku






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 3:19









      Eduard DamiamEduard Damiam

      62




      62






















          1 Answer
          1






          active

          oldest

          votes


















          0














          It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere.
          That is from the line



          var port_number = server.listen(process.env.PORT || 3000);


          Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on.
          I think you would want:



          var port_number = process.env.PORT || 3000;
          app.listen(port_number);





          share|improve this answer























          • i change it just like you say, but it didn't work

            – Eduard Damiam
            Nov 14 '18 at 3:45











          • Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

            – Joseph
            Nov 14 '18 at 5:01











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292710%2fheroku-web-process-failed-to-bind-to-port-within-60-seconds-of-launch%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere.
          That is from the line



          var port_number = server.listen(process.env.PORT || 3000);


          Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on.
          I think you would want:



          var port_number = process.env.PORT || 3000;
          app.listen(port_number);





          share|improve this answer























          • i change it just like you say, but it didn't work

            – Eduard Damiam
            Nov 14 '18 at 3:45











          • Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

            – Joseph
            Nov 14 '18 at 5:01
















          0














          It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere.
          That is from the line



          var port_number = server.listen(process.env.PORT || 3000);


          Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on.
          I think you would want:



          var port_number = process.env.PORT || 3000;
          app.listen(port_number);





          share|improve this answer























          • i change it just like you say, but it didn't work

            – Eduard Damiam
            Nov 14 '18 at 3:45











          • Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

            – Joseph
            Nov 14 '18 at 5:01














          0












          0








          0







          It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere.
          That is from the line



          var port_number = server.listen(process.env.PORT || 3000);


          Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on.
          I think you would want:



          var port_number = process.env.PORT || 3000;
          app.listen(port_number);





          share|improve this answer













          It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere.
          That is from the line



          var port_number = server.listen(process.env.PORT || 3000);


          Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on.
          I think you would want:



          var port_number = process.env.PORT || 3000;
          app.listen(port_number);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 3:32









          JosephJoseph

          363




          363












          • i change it just like you say, but it didn't work

            – Eduard Damiam
            Nov 14 '18 at 3:45











          • Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

            – Joseph
            Nov 14 '18 at 5:01


















          • i change it just like you say, but it didn't work

            – Eduard Damiam
            Nov 14 '18 at 3:45











          • Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

            – Joseph
            Nov 14 '18 at 5:01

















          i change it just like you say, but it didn't work

          – Eduard Damiam
          Nov 14 '18 at 3:45





          i change it just like you say, but it didn't work

          – Eduard Damiam
          Nov 14 '18 at 3:45













          Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

          – Joseph
          Nov 14 '18 at 5:01






          Is your server variable defined in the file somewhere? I am thinking that the line with that call (server.listen) will cause an error, so that the app.listen() call is not getting executed. I was thinking, if you put a callback function in the app.listen call, (the second argument, after the port_number), that console.logs to the screen, just to make sure it is running. ` app.listen(port_number, () => console.log("API Server now listening on PORT " + port_number + "!); ); `

          – Joseph
          Nov 14 '18 at 5:01


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292710%2fheroku-web-process-failed-to-bind-to-port-within-60-seconds-of-launch%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto