Error 502 is being returned by the Nginx server for specific directories within the Express Application

Currently, I have an express application running on Ubuntu with nginx as the web server. Everything was functioning correctly until today when I attempted to add two new directories using the app.get method and re-deployed my app. Unfortunately, the new directories are not working and instead, I am encountering 502 Bad Gateway errors (the old directories continue to work properly). I have tried restarting pm2, nginx, and the server itself but it did not resolve the issue. Any suggestions on what steps I should take next?

Answer №1

It took me a few hours to figure out that the issue was actually in my code and not related to nginx. Luckily, with pm2 running on the server, it didn't crash and helped me uncover the mistake. Here is the command I ran to diagnose the problem:

node server.js

And that's how I finally discovered the error.

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

Connect Promise.all() with an array of identification numbers

I'm fairly new to working with Promises and I have a question regarding linking the results of `Promises.all()` to unique IDs for each promise once they resolve. Currently, I am making requests to a remote server and retrieving data for each request. ...

Error: A sudden termination of multipart data was encountered during a post request in a node.js application

Attempting to retrieve an image via busboy in a Node.js post call is resulting in the following error: Error: Unexpected end of multipart data thrown by ..\node_modules\dicer\lib\Dicer.js:61:28 This snippet shows the code being used: ...

Troubleshooting the transition from React version 16.0.0 to React version 18

I am encountering issues with my package.json file and Jenkins build, which fails due to the following problems. I'm currently running npm version 8.15.0 and Node version v16.17.1, while trying to upgrade from React 16 to React 18. package.json { & ...

Unable to extract query parameters from URL using Express JS as req.query returns an empty object

I came across discussions about this issue here and here, but unfortunately, the solutions provided didn't work for me. I'm attempting to extract parameters from the URL using req.query. In my server.js file, I've implemented the following: ...

Having trouble with pm2 starting up correctly?

I have encountered an issue while trying to launch a nodejs application in pm2 on bluehost shared hosting. When I run the command pm2 start ./bin/www, the server fails to start and displays the following message: [PM2] Spawning PM2 daemon with pm2_home=/h ...

Create a ReactJS page with no pre-generated additional pages

Just ventured into the world of reactjs and created my first app. Now I'm trying to build a production version using the command: npm run build However, all I get is a blank index.html file generated. Why is this happening? I have multiple routes in ...

"Encountering errors when attempting to create a course with Active status using a service account through the Google Classroom API

I am utilizing googleapis in order to establish a classroom course using a service account. Everything runs smoothly when I do not specify the status, and the course is created with status: PROVISIONED. However, when I attempt to update the status to ACTI ...

What is the best way to incorporate a variable in the find() method to search for similar matches?

I've been working on a dictionary web application and now I'm in the process of developing a search engine. My goal is to allow users to enter part of a word and receive all similar matches. For instance, if they type "ava", they should get back ...

Finding the Node.js log location during deployment in Heroku

My Node app on Heroku is giving me trouble. It deploys without any errors, but it crashes right at the start. The log provided below doesn't point to the issue clearly. When I try to access the suggested log at .npm/_logs/2021-04-22T19_59_52_474Z-debu ...

Experiencing lengthy delays when sending AT commands to Huawei E3131 modem for AT+CMGS result

Am I experiencing a delay of around 30 seconds when receiving results from AT+CMGS="my phone number"\r? Here is the sequence of commands: REQ: AT RES: AT RES: OK REQ: AT+CMGF=1 RES: AT+CMGF=1 RES: OK REQ: AT+CMGS="+4xxxxxxxxxx" RES: AT+CMGS="+4xxx ...

Organizing AngularJS controllers in separate files

I am facing a challenge with my cross-platform enterprise app that is built using Onsen UI and AngularJS. The app has been growing rapidly in size, making it confusing and difficult to manage. Until now, I have kept all the controllers in one app.js file a ...

When a button is clicked, retrieve information from a server using Node.js

In my front end code, I have a scenario where upon clicking a button, I need to retrieve specific data from the node server to populate a map on the client side. The map can be viewed at: "http://localhost:8080/" Here's how I'm making the reques ...

How can I resolve the error that says "Module 'util-deprecate' not found in npm"?

As I was trying to install a module using NPM, an unexpected error occurred. Error: Module 'util-deprecate' not found After multiple failed attempts to resolve the issue, including uninstalling and reinstalling Node.js, the same error continued ...

The idleTimer plugin appears to be malfunctioning

I have been working on implementing an automatic logout feature for users who remain idle for a specific amount of time on a particular page. My approach involves using jade files to structure the layout of my html pages. I attempted to integrate the idleT ...

Unable to execute requirejs on heroku platform

Looking for some advice on using nodejs + requirejs on heroku. The project structure is quite common: \ |-\app |-\build |-\config |-\node-modules |-\public | |-server.js |-etc... After running "gulp build", the build folder ...

Guide on how to programmatically assign a selected value to an answer using Inquirer

Currently, I'm utilizing inquirer to prompt a question to my users via the terminal: var inquirer = require('inquirer'); var question = { name: 'name', message: '', validation: function(){ ... } filter: function( ...

Is there a way to assign the output of stdout.pipe in Node.js to a variable?

How can I execute the linux shell command "free -m" and save its output into a variable using the following code: var spawn = require('child_process').spawn, command = spawn('free', ['-m']); command.stdout.pipe(proces ...

Unable to authenticate the initial certificate with Node

Out of the blue, my Node environments are experiencing issues with installing packages and freezing at idealTree:my-app : sill idealTree buildDeps Although I attempted to fix it by using npm config set registry http://registry.npmjs.org/ --global, it didn ...

"Exposing Data: The Vulnerability of NodeJS with

After encountering an issue with my code, I attempted to resolve it by initially using a simple try/catch block. However, this did not work as expected so I decided to switch to a callback-based error handler: var addblockeduser = function(x,y,next) { ...

Exploring the capabilities of Express.JS for integrating with an external API

const express = require('express'); const app = express(); const path = require('path'); const api = require('./api'); app.get('/', function(req, res){ res.sendFile(path.join(__dirname + '/index.html')); ...