Encountering Issue H12 While Deploying an Express JS Application on Heroku

I have developed an application using Node JS, and I've taken it as far as I can on my local machine. Now, I need to deploy it on Heroku.

If you want to check out the main server.js file, you can find it here: http://pastebin.com/6VGk8ESz. To understand how routing is set up, take a look at this Lib file: http://pastebin.com/uirpUFkq

The issue I'm facing is that while the app works perfectly fine locally, when I try to upload it to Heroku, I consistently receive the following error message:

at=error code=H12 desc="Request timeout" method=GET path=/ host=careboxnode.herokuapp.com fwd="64.129.24.13" dyno=web.1 connect=8ms service=30002ms status=503 bytes=0

I've added console.log() statements throughout my code, and everything seems to be running smoothly without any errors. However, both res.render and res.send do not seem to be sending any content back to Heroku for serving, leading to timeouts. I haven't encountered any formal errors or exceptions, and all files are being read correctly. It's just the display of content that isn't working.

This problem has me stumped, so any help or insights anyone can provide would be greatly appreciated! Thank you in advance! :)

Answer №1

It appears that there are two bugs in your code. One of the issues is most likely related to using localhost and a static port for connecting to the database. When deploying on Heroku, you should be getting the database URL through an environment variable.

Furthermore, it's crucial to also fetch the web port from Heroku, as demonstrated in this link: https://devcenter.heroku.com/articles/nodejs#write-your-app

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

Gulp is unable to successfully make an API post request

I am facing an issue where a specific request is not successful. Although I receive a response, it is not the desired success response. The request works fine when sent from Postman, but encounters problems when executed in Gulp. var proj = { "APIKey" ...

The environment variable was not properly included in the container's environment

Behold, my Dockefile FROM ubuntu:latest MAINTAINER mazzy WORKDIR /tmp RUN apt-get update && apt-get install -y wget RUN wget http://nodejs.org/dist/v0.12.0/node-v0.12.0-linux-x64.tar.gz RUN tar xvf node-v0.12.0-linux-x64.tar.gz RUN cp -r node- ...

Launching ReactJS and ExpressJS on Nginx server

I am currently running an Ubuntu VPS setup (version 20.04LTS) with Nginx Server installed. Within the setup, I have two separate local repositories - one for front-end ReactJS code and another for back-end ExpressJS code. To run the ExpressJS code, I will ...

Could using 'require' in node.js lead to a memory leak issue?

I have been working on a program that experiences continuous heap growth. The program is quite simple - it repeatedly tries to load an external file (SyntaxError) using require. However, this external module fails to load due to a syntax error present in i ...

Our express.js does not recognize GET requests from routers

When placeholders and predefined routes coexist in the same location, the predefined routes are never called if the placeholder was declared before them. For example: router.get("/:id", fetchEntry) router.get("/fancy-action/", doSomet ...

Exploring the benefits of using Styled Components for creating global styles in React and Next.js: Should you opt for a mix of CSS files and Styled Components?

Recently, I implemented Styled Components in my Next.js app by following the guidelines from Styled Components. Currently, I am delving into the realm of best practices for managing global styles with Styled Components. The first aspect that piques my curi ...

Unlocking the full potential of Nodejs involves mastering the art of obtaining Entities in synchronous

I am attempting to retrieve data from a storage account's Table. I managed to successfully obtain the data using the method detailed here. However, this method utilizes callbacks. My objective is to retrieve the results synchronously! ...

Having issues with npm installing the bassaudio library

I've been attempting to add the bassaudio library to my project, but every npm installation attempt results in an error. No matter what troubleshooting steps I take, the issue persists. The specific error message I encounter when running npm install b ...

What is the Redux Toolkit equivalent of setting fetch's { credentials: "include" } in createApi?

In my project, I am utilizing an express-react-typescript-redux-passport setup where I'm making use of createApi from Redux Toolkit to make a call to a /getuser API on the backend. The authentication process involves the use of the passport-google-oa ...

Terminate PM2 in cluster mode

Oops, I accidentally ran the command below on the server pm2start app.js -i 3500 Now multiple instances are being created in cluster mode on the server. Can someone please advise me on how to stop this? And is there a way to delete the already running ins ...

An issue was encountered at node_modules/@fullcalendar/core/main.d.ts(1196,54), error TS1144: Expecting either '{' or ';'

When attempting to execute npm run build in my project, I encountered the following error: ERROR in node_modules/@fullcalendar/core/main.d.ts(1196,54): error TS1144: '{' or ';' expected. node_modules/@fullcalendar/core/main.d.ts(1197,34 ...

The data received from the frontend is being replicated in the backend, causing duplication issues in a React

Whenever I click the button labeled onClick, it triggers the transmission of data (both time and ID) to the backend. The issue at hand is that the backend seems to be receiving the data twice instead of just once. On inspecting req.body, it becomes eviden ...

The method `sort` is not a recognized function in Sequelize Express Node when using `models.Page.findOne(...)

After successfully importing the models and inserting data, I am now trying to retrieve page indexes using a specific method. Can anyone provide assistance with this? /* * Get Page model // */ router.get('/',function(req,res){ models.Page.f ...

What are the steps to fix the "Cannot GET /" error in a Kubernetes deployment?

In my node.js application called "process-core," I am responsible for running another node.js app known as "page-core." The main task of "Process-core" is to deploy the distribution folder (static contents) of the "page-core" application using Kubernetes. ...

Learn the steps to establish a one-to-many relational record with the help of Node.js and Sequelize-Typescript

Currently, I am working on Nodejs with sequelize-typescript to develop a CRUD system for a one-to-many relationship. Unfortunately, I have encountered an issue with my code that I cannot seem to pinpoint. While I am able to retrieve records successfully us ...

``The problem of cross-origin resource sharing (CORS)

Encountering a CORS error when sending the request, although it works fine in Postman Error Message: The fetch request to (cloud function url) from my web app origin is being blocked by CORS policy: No 'Access-Control-Allow-Origin' header is p ...

What is the process for incorporating ejs into the source attribute of an image element?

Code Snippet: <img class="card-img-top" alt="..."><%= articles.image %><img> Server Setup: const express = require('express') const app = express() const router = require('./routes/article') app ...

Encountered a problem while rendering the app: [TypeError: Unable to assign a value to the property 'content' since it is undefined]. Implementing Express with

My experience with res.render is flawless: res.render('main', function(err, html){ // Displays '<html></html>' from 'views/main.html' console.log(html); }); However, the situation changes when it comes to ...

Deselect all event listeners excluding the ones specified in Socket.io

I have a node.js application using socket.io to dynamically load external modules, referred to as "activities," in real-time. Each module binds its own events to the sockets, so when switching from one module to another, I need to remove all event listene ...

What steps do I need to take to set up Webstorm 10 so that it automatically runs npm install --force before

Is there a way to configure my debug settings in Webstorm so that I can automatically run "npm install --force" on a shared submodule before launching the application for debugging? This would save me time and ensure that everything is set up properly. I ...