oog
oog
RRailway
Created by oog on 2/5/2024 in #✋|help
Unable to deploy express.js project: EADDRINUSE: address already in use
Hello, I was trying to deploy a new service consisting of a express.js server and was having trouble getting it to deploy. I have another service that is also using express that is working perfectly fine, and I have this one setup in the exact same way (using the PORT env to listen on) but this one seems to have trouble listening on any given port. I have also tried specifying 0.0.0.0 with no luck. Thanks in advance! Error log:
Now listening at http://localhost:8059!
node:internal/errors:496
ErrorCaptureStackTrace(err);
^
Error: listen EADDRINUSE: address already in use 127.0.0.1:8059
at Server.setupListenHandle [as _listen2] (node:net:1817:16)
at listenInCluster (node:net:1865:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:2014:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:110:8) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '127.0.0.1',
port: 8059
}
Node.js v18.18.2
Now listening at http://localhost:8059!
node:internal/errors:496
ErrorCaptureStackTrace(err);
^
Error: listen EADDRINUSE: address already in use 127.0.0.1:8059
at Server.setupListenHandle [as _listen2] (node:net:1817:16)
at listenInCluster (node:net:1865:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:2014:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:110:8) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '127.0.0.1',
port: 8059
}
Node.js v18.18.2
Express server code:
const port = process.env.PORT || 3000;

import express from 'express';
import { handler as ssrHandler } from './dist/server/entry.mjs';

const app = express();
app.use(express.static('dist/client/'));
app.use((req, res, next) => {
ssrHandler(req, res, next, locals);
});

app.listen(port, () => {
console.log(`Now listening at http://localhost:${port}!`)
})
const port = process.env.PORT || 3000;

import express from 'express';
import { handler as ssrHandler } from './dist/server/entry.mjs';

const app = express();
app.use(express.static('dist/client/'));
app.use((req, res, next) => {
ssrHandler(req, res, next, locals);
});

app.listen(port, () => {
console.log(`Now listening at http://localhost:${port}!`)
})
Project ID: ed6d3edc-13cb-4f94-98af-04578f1a1a67
22 replies