Error: listen EADDRINUSE: address already in use

I’m getting the below error
throw er; // Unhandled ‘error’ event
^
Error: listen EADDRINUSE: address already in use::: 3000
at Server.setupListenHandle[as _listen2](net.js: 1270: 14)
at listenInCluster(net.js: 1318: 12)
at Server.listen(net.js: 1405: 7)
at DBLWebhook._startWebhook(/rbd/pnpm - volume / 9 bec958d - aa60 - 4970 - 80 ef - 0 d7a9058ba8a / node_modules / .registry.npmjs.org / dblapi.js / 2.4 .0 / node_modules / dblapi.js / src / webhook.js: 45: 18)
at new DBLWebhook(/rbd/pnpm - volume / 9 bec958d - aa60 - 4970 - 80 ef - 0 d7a9058ba8a / node_modules / .registry.npmjs.org / dblapi.js / 2.4 .0 / node_modules / dblapi.js / src / webhook.js: 27: 12)
at new DBLAPI(/rbd/pnpm - volume / 9 bec958d - aa60 - 4970 - 80 ef - 0 d7a9058ba8a / node_modules / .registry.npmjs.org / dblapi.js / 2.4 .0 / node_modules / dblapi.js / src / index.js: 69: 22)
at Client.client.on(/app/index.js: 207: 15)
at Client.emit(events.js: 194: 15)
at WebSocketConnection.triggerReady(/rbd/pnpm - volume / 9 bec958d - aa60 - 4970 - 80 ef - 0 d7a9058ba8a / node_modules / .registry.npmjs.org / discord.js / 11.6 .2 / node_modules / discord.js / src / client / websocket / WebSocketConnection.js: 128: 17)
at WebSocketConnection.checkIfReady(/rbd/pnpm - volume / 9 bec958d - aa60 - 4970 - 80 ef - 0 d7a9058ba8a / node_modules / .registry.npmjs.org / discord.js / 11.6 .2 / node_modules / discord.js / src / client / websocket / WebSocketConnection.js: 144: 61)
Emitted ‘error’
event at:
at emitErrorNT(net.js: 1297: 8)
at process._tickCallback(internal / process / next_tick.js: 63: 19)

the code I’m using is

app.listen(process.env.PORT);
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

and

  const dbl = new DBL('myapikey', { webhookPort: process.env.PORT, webhookAuth: 'dblapi.js' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
  
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

I’m assuming this is coming from me using the same port twice, so how do I set a different port?

Maybe try using with the 80 port?

@SplitXPlayZ I asked how to set the port, I figured the error was the duplicate port so…

OK, this forum is solved.

How do you set the port? you still didn’t answer that.
When I try, I get the error

  throw er; // Unhandled 'error' event
  ^
Error: listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1253:19)
at listenInCluster (net.js:1318:12)
at Server.listen (net.js:1405:7)
at DBLWebhook._startWebhook (/rbd/pnpm-volume/9bec958d-aa60-4970-80ef-0d7a9058ba8a/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:45:18)
at new DBLWebhook (/rbd/pnpm-volume/9bec958d-aa60-4970-80ef-0d7a9058ba8a/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:27:12)
at new DBLAPI (/rbd/pnpm-volume/9bec958d-aa60-4970-80ef-0d7a9058ba8a/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:69:22)
at Client.client.on (/app/index.js:207:15)
at Client.emit (events.js:194:15)
at WebSocketConnection.triggerReady (/rbd/pnpm-volume/9bec958d-aa60-4970-80ef-0d7a9058ba8a/node_modules/.registry.npmjs.org/discord.js/11.6.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:128:17)
at WebSocketConnection.checkIfReady (/rbd/pnpm-volume/9bec958d-aa60-4970-80ef-0d7a9058ba8a/node_modules/.registry.npmjs.org/discord.js/11.6.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:144:61)
Emitted 'error' event at:
at emitErrorNT (net.js:1297:8)
at process._tickCallback (internal/process/next_tick.js:63:19)

80 port is denied on glitch, sorry my bad.
Have you tried on 3000 port?

3000 is the default, which is the one throwing the error.

Try posting the webhook on 8080 perhaps, may it works.

1 Like

you should always use the port that glitch sets in process.env.PORT, which is usually 3000. anything else won’t be open

1 Like

Glitch only allows port 3000, any other port will always EACCES

Hey @Ghostoblivion,

The only port available for a Glitch project container is port 3000.

To set the port at 3000, make sure you have this code at the bottom of your server.js (or the main script file):

const listener = app.listen(process.env.PORT, () => {
  console.log("Your app is listening on port " + listener.address().port);
});

3000 is a combination of two ports, meaning we could use these two if we know which they are

1 Like