An Interest In:
Web News this Week
- March 6, 2024
- March 5, 2024
- March 4, 2024
- March 3, 2024
- March 2, 2024
- March 1, 2024
- February 29, 2024
Some of Our Sources
View All SourcesPM2 listening on port 443 shows EADDRINUSE: address already in use :::443
I have a Node/Express app running on an AWS Lightsail instance with PM2 as a process manager. The app is currently running on port 4000. The IP address for the instance is attached to a subdomain that has a valid SSL certificate and automatically redirects from HTTP to HTTPS. Visiting https://example.com at the moment shows the 'Congratulations! You are now running Bitnami Node.js 12.18.3 in the Cloud.' page.
Currently, all the Express endpoints are only accessible through http://example.com:4000/endpoint, but I want the Express app to run on port 443 so that the endpoints are accessible immediately on https://example.com/endpoint.
I read that PM2 is able to listen on ports 80 and 443 and tried the method mentioned in the documentation, but whenever I change the port number in the .env file to 443 and reload the app using pm2 reload app
, I get the following error:
0|app | Error: listen EADDRINUSE: address already in use :::4430|app | at Server.setupListenHandle [as _listen2] (net.js:1313:16)0|app | at listenInCluster (net.js:1361:12)0|app | at Server.listen (net.js:1447:7)0|app | at Function.listen (/opt/bitnami/apache/htdocs/node_modules/express/lib/application.js:618:24)0|app | at Object.<anonymous> (/opt/bitnami/apache/htdocs/app.js:44:5)0|app | at Module._compile (internal/modules/cjs/loader.js:1137:30)0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)0|app | at Module.load (internal/modules/cjs/loader.js:985:32)0|app | at Function.Module._load (internal/modules/cjs/loader.js:878:14)0|app | at Object.<anonymous> (/opt/bitnami/node/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) {0|app | code: 'EADDRINUSE',0|app | errno: 'EADDRINUSE',0|app | syscall: 'listen',0|app | address: '::',0|app | port: 4430|app | }
App.js
const express = require('express');const dotenv = require('dotenv');const app = express();app.use(express.json()); // for parsing POST bodiesdotenv.config();app.get("/hello", (req, res) => res.send("Hello World!"));app.listen(process.env.PORT, () => { console.log(` App listening on port ${process.env.PORT}!`);});
.env
PORT=443
The output of pm2 status
at the moment:
Any help would be appreciated!
Original Link: https://dev.to/dmahely/pm2-listening-on-port-443-shows-eaddrinuse-address-already-in-use-443-1aho
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To