Error, adress already in use ::3000

Question:
So i have this express server and i’m using port 35535. I’ve only recently been starting to get this error on my node.js projects after the consoles ui updated for me, but i don’t know for sure if that’s the cause. The website itself still works but this error gets in the way of other error handling and console logs. Ive tried to change the port while yes that does work for a while, the error comes back. i don’t even understand why its giving that error, does localhost even work on replit?

Repl link:
front page:
https://replit.com/@OwenStritz/passportjs?v=1
website:
https://passportjs.owenstritz.repl.co
Code:

app.listen('35535', () => {
  console.log('listening to port 3000');
});

exact error because i think only i can see it

Error: Listen EADDRINUSE: address already in use : ::35535
at server.setupListenHandle [as _listen2] (node:net:1740:16)
at listenInCluster (node:net:1788:12)
at Server.listen (node:net:1876:7)
at Function.listen (/home/runner/passport.js/node_modules/express/lib/application.js:635:24)
at Object. <anonymous> (/home/runner/passportjs/index.js:89:5)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

(im to lazy to right the rest… sorry)

Well let’s go by parts

EADDRINUSE means that the port you’re trying to bind your server to is already in use by another process.

Why are you listening to port 3000? Just listen to the port you’re supposed to?

const PORT = 35535;
app.listen(PORT, () => {
  console.log(`listening to port ${PORT}`);
});

So, you can use Dynamic Port Assignment too (which means let the operating system assign a port dynamically).

2 Likes