Encountering an Issue on Heroku with Node.js - Error R10 (Boot timeout) -> The web process was unable to connect to

When trying to deploy my website on Heroku, I encountered the following error message:

Application error

An error occurred in the application and the page could not be served. As the application owner, I checked the logs for details as suggested by Heroku CLI using the command Heroku logs --tail

Upon checking the logs, there doesn't seem to be any major issues. The information displayed was:

2020-09-20T23:56:47.790226+00:00 app[web.1]: 

2020-09-20T23:56:48.040459+00:00 app[web.1]: SERVER IS RUNNIG AT PORT 8000

2020-09-20T23:56:48.040768+00:00 app[web.1]: Server running at http://127.0.0.1:5500

2020-09-20T23:57:44.991177+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

2020-09-20T23:57:45.017244+00:00 heroku[web.1]: Stopping process with SIGKILL

2020-09-20T23:57:45.087257+00:00 heroku[web.1]: Process exited with status 137

2020-09-20T23:57:45.132990+00:00 heroku[web.1]: State changed from starting to crashed

2020-09-21T02:05:44.125661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sheetsw.herokuapp.com request_id=b87a2aae-a1d1-44d4-9f4e-2d10421edec6 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https

2020-09-21T02:05:46.906817+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sheetsw.herokuapp.com request_id=a46e447c-e111-4954-a6c6-a1e928013a82 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https

2020-09-21T02:06:05.637299+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sheetsw.herokuapp.com request_id=d6aa7d9b-60eb-450c-8ceb-c063faad3917 fwd="27.60.151.127" dyno= connect= service= status=503 bytes= protocol=https

I am seeking guidance on what might be causing this issue and how I can resolve it. Any help would be appreciated.

This is a snippet from my server.js file:

    const express = require("express");

const fs = require('fs');

const nodemailer = require('nodemailer');
const  bodyParser = require('body-parser');

const hostname= '127.0.0.1';
const port= 5500;

const path = require('path');

const app = express();

app.get('/register.html',(req,res) => {

 res.sendFile(__dirname + '/register.html')
})

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
sending();

function sending(){
   

const transporter = nodemailer.createTransport({
    service:'gmail',
    auth:{
        user:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1774787b7b727463797e6457707a767e7b3974787a">[email protected]</a>',
        pass:'free_fire123'        
    }
});

function sendEmail(mail)
{
 var mailOptions= {
     from: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea898586868f899e848399aa8d878b8386c4898587">[email protected]</a>',
     to:mail.to,
     subject: mail.subject,
     html: mail.body
 }

transporter.sendMail(mailOptions, function(err, info) {
    if(err){
        console.log(err+"                    "+mail.to)
    }
    else {
        console.log("Email sent: "+info.response)
    }
})
}

app.post('/register.html', (req,res)=> {
    mail= {
        to:req.body.to_address,
        subject:"Sheets_Wrap - project details",
        body:req.body.NAME + "    ------------/////////////------------     "+ req.body.phone + "    ------------/////////////------------     " + req.body.email_body + "    ------------/////////////------------     " + req.body.code
    }
    sendEmail(mail)
    res.redirect('/register.html')
})


app.listen(port, ()=> {
    console.log('SERVER IS RUNNIG AT PORT 8000')
    console.log(`Server runnung at http://localhost:${port}/register.html`);
})
}

Answer №1

Problem: Your Node.js application is not properly set up to connect to the port assigned by Heroku through the $PORT environment variable.

Heroku dynos provide a dynamic port for your application to connect to. This value can be accessed using the $PORT environment variable. You need to modify your code so that it connects to this port instead. Here's an example:

//Update your hard-coded port to use process.env.PORT
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Our app is now running on port ${ PORT }`);
});

This will utilize the $PORT environment variable if it exists, or default to a specific port (ideal for local development). Remember that even when accessing your application on Heroku, you still use port 80 ([your-application].herokuapp.com) and not the one your application binds to.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

unable to bypass mongoose nested documents

I'm currently working with mongoose and node in an effort to paginate data from sub-documents. I've managed to limit the subdocuments, but skipping them seems to be a challenge. The specific versions I'm using are: Mongo 3.0.0 Node 0.10.3 ...

Personalized jQuery Slider, Go back to initial slide

Working on enhancing my jQuery skills by constructing a basic slider with 3 slides. The slider wrapper, with a fixed width of 1400px and a height of 350px serves as the outer container. Within this wrapper lies an unordered list where its items are floate ...

Struggling to generate a cookie through an express middleware

I'm currently working on setting up a cookie for new user registrations in my app to track their first login attempt. I came across this thread which provided some guidance but I'm still facing issues. Below is the snippet of my code: // Middle ...

Ways to display a div based on the value quantity

Is it possible to display a div based on the value provided? Check out my code on Fiddle! jQuery(function () { jQuery('#btn_test').click(function () { $(this).parent().children('#test_inner').slideToggle('500' ...

Here is a unique version: "Learn how to efficiently transfer data from multiple parent elements to another page using the same buttons by leveraging LocalStorage

I received assistance from mplungjan to create part of the code. Currently, I have created multiple buttons for various paragraphs, functioning as favorite buttons. My goal is to transfer these favorited paragraphs to a different page. For more details, yo ...

Retrieving the checkbox value from a dropdown selection

I'm stuck and feeling lost here - I must be missing something obvious. Any help will be greatly appreciated! (I am a beginner in html and javascript) I have created a dropdown menu with an unordered list of items populated from JSON data. Here is the ...

I am currently encountering a glitch with my video VTT file, as the subtitles are not appearing on screen

welcome to the world of coding WEBVTT 00:01.000 --> 00:8.000 coding is my passion join me on this journey ...

What is the best way to use ajax to load a particular div or class from a file?

In my main.html file, there are several divs each with 2 classes. The first is their specific class and the second is a class called menu-item, which determines if an event will be triggered when clicked. For example: <div id="load-here"> </div ...

Tips on extracting all selectable text from a webpage using Python

Currently, I am tackling a web scraping project that involves extracting all copyable text from a visually displayed web page. I experimented with various techniques such as parsing the HTML code based on keywords, but unfortunately, I encountered roadblo ...

Utilize a CompareValidator to evaluate conditions only when necessary

I am dealing with a checkbox containing a javascript function that triggers onclick to toggle the visibility of a div. Within this div, there is a textbox with a CompareValidator that validates the input as a Double. The issue arises when the checkbox is ...

Email sending through PHP AJAX can be done without refreshing the page. The email action is handled in email.php and incorporated into

I am having trouble sending this with AJAX. The error message I keep getting is: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more assistance, please visit @ jquer ...

Having problems with the MongoDB save() function when it comes to an array of objects

This piece of code is designed to handle post requests for sending messages between users. It works well when the message is not part of an existing message string (i.e., typeof existingMessageIndex === 'undefined'). The error ("error saving outg ...

Exploring Node Streams: Tracking 'unpipe' Events in a Readable Stream

After setting up a read stream that connects to an SFTP and starts fetching data from a file, I encountered a challenge. In my code, I can terminate the read stream at any point and proceed with other actions. For example, I may use this feature to extract ...

What is the best way to design a white arrow with a subtle touch of grey outlining?

Question: I am interested in creating a left-pointing arrow with a grey border. Currently, I have only managed to create a grey arrow without a border. Is there any way I can achieve this? Attached is a picture to illustrate what I'm looking for. An ...

Eliminate dropdown arrow in Internet Explorer

I am working on customizing a select element by removing the arrow and adding a different icon. So far, I have successfully achieved this for Firefox, Safari, and Chrome. However, I am facing an issue with IE9. .styled-select select { border: 0 !impo ...

What is the best way to locate a deeply nested object within arrays in MongoDB?

I'm currently navigating my way through MongoDB and facing challenges with crafting a specific query for an upcoming project. The data structure I am working with is as follows (in a simplified form): games: {_id: ..., scenes: [{_id: ..., views: [{ ...

The jQuery html function may encounter issues when used in Chrome browser

Can someone help me figure out why this code isn't functioning properly in Chrome, even though it works fine in Safari? I've been searching for a solution but haven't had any luck! jQuery.noConflict(); jQuery(document).ready(function() { ...

Tips for verifying the inputted text in a search box with Selenium in Node.js and Mocha chai

Looking to perform validation on the string entered into the "Google search box" Upon running the following code in Node.js, an error is encountered: Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test. Below is th ...

Measure the complete duration or elapsed time of a test suite by utilizing the Jasmine Hook

I have been attempting to retrieve the 'totalTime' from the jasmineDone hook or the 'duration' from SuiteResult as mentioned in the documentation at [, but unfortunately, they do not appear to be accessible. Any guidance would be greatl ...

"Discovering hidden features of Django when using the pyexcel library for creating Excel files on a

After deploying my Django app on Heroku, I encountered an issue with uploading Excel xlsx files. An error message stating UnknownParameters appeared: Please check if there were typos in function parameters: {'model': None, 'initializer' ...