I am having a NodeJS application with some basic routes and sql server connectivity. I am using pkg for the executables. All the configuration settings are stored on .env file. When I am trying to run multiple instance of the application from different directories with different port number specified in the .env file, my app is crashing with "EADDRINUSE" error code and says the particular port is used. I am able to run only single instance of application with any defined port number in .env file. I didn't explicitly use any default port number in the application.
"use strict";
const express = require("express");
const mac = require("./auth/auth");
const ejs = require("ejs");
var log = require('./utils/scroll');
var bodyParser = require("body-parser");
const app = express();
app.use(require('./utils/init'));
app.use(bodyParser.urlencoded({ extended: true, limit: "500mb"}));
app.use(bodyParser.json({limit: "500mb"}));
app.use(require('./utils/cors'));
app.use('/',require('./routes'));
console.log(mac);
var port = (process.env.port);
log();
app.use("/", express.static("assets"));
app.set("view engine", "ejs");
app.listen(port,()=>{
console.log("Server Running at Port :", port);
});
Is there any other setting I have to do?.
I had tried configuring different .env files with different port numbers per application.