EADDRINUSE error when running multiple API instances #566

Closed
opened 2025-11-09 09:52:39 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @userlip on GitHub (Nov 14, 2024).

bug description

When starting the API instance with more than 1 instance in the .env it will end up with a EADDRINUSE error

`

pnpm start

@imput/cobalt-api@10.3.1 start /home/ploi/cobalt/api
node src/cobalt

[✓] cobalt sub-instance running on 127.0.0.1:40323
[✓] cobalt sub-instance running on 127.0.0.1:35095
[✓] cobalt sub-instance running on 127.0.0.1:36197
[✓] cobalt sub-instance running on 127.0.0.1:43077
[✓] cobalt sub-instance running on 127.0.0.1:45071
[✓] cobalt sub-instance running on 127.0.0.1:45375
[✓] cobalt sub-instance running on 127.0.0.1:34861
node:events:496
throw er; // Unhandled 'error' event
^

Error: listen EADDRINUSE: address already in use :::3001
at Server.setupListenHandle [as _listen2] (node:net:1907:16)
at listenInCluster (node:net:1964:12)
at Server.listen (node:net:2066:7)
at runAPI (file:///home/ploi/cobalt/api/src/core/api.js:350:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1943:8)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3001
}

Node.js v22.11.0
[✓] cobalt sub-instance running on 127.0.0.1:43537
[✓] cobalt sub-instance running on 127.0.0.1:42271
 ELIFECYCLE  Command failed with exit code 1.

`

reproduction steps

  1. Download the latest code from this repo
  2. Install all the things as described in the Documentations
  3. use this .env:

API_URL="https://cobalt.test.com/"
API_PORT=3001
API_INSTANCE_COUNT=10
API_REDIS_URL=redis://localhost:6379

  1. pnpm start

screenshots

No response

No response

platform information

Ubuntu 24.04

additional context

No response

Originally created by @userlip on GitHub (Nov 14, 2024). ### bug description When starting the API instance with more than 1 instance in the .env it will end up with a EADDRINUSE error ` pnpm start > @imput/cobalt-api@10.3.1 start /home/ploi/cobalt/api > node src/cobalt [✓] cobalt sub-instance running on 127.0.0.1:40323 [✓] cobalt sub-instance running on 127.0.0.1:35095 [✓] cobalt sub-instance running on 127.0.0.1:36197 [✓] cobalt sub-instance running on 127.0.0.1:43077 [✓] cobalt sub-instance running on 127.0.0.1:45071 [✓] cobalt sub-instance running on 127.0.0.1:45375 [✓] cobalt sub-instance running on 127.0.0.1:34861 node:events:496 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE: address already in use :::3001 at Server.setupListenHandle [as _listen2] (node:net:1907:16) at listenInCluster (node:net:1964:12) at Server.listen (node:net:2066:7) at runAPI (file:///home/ploi/cobalt/api/src/core/api.js:350:28) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) Emitted 'error' event on Server instance at: at emitErrorNT (node:net:1943:8) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 3001 } Node.js v22.11.0 [✓] cobalt sub-instance running on 127.0.0.1:43537 [✓] cobalt sub-instance running on 127.0.0.1:42271  ELIFECYCLE  Command failed with exit code 1. ` ### reproduction steps 1. Download the latest code from this repo 2. Install all the things as described in the Documentations 3. use this .env: API_URL="https://cobalt.test.com/" API_PORT=3001 API_INSTANCE_COUNT=10 API_REDIS_URL=redis://localhost:6379 4. pnpm start ### screenshots _No response_ ### links _No response_ ### platform information Ubuntu 24.04 ### additional context _No response_
GiteaMirror added the bug label 2025-11-09 09:52:40 -06:00
Author
Owner

@wukko commented on GitHub (Nov 14, 2024):

this means that something else uses the 3001 port on your machine and cobalt can’t use it. try a different port or free up the 3001 port.

@wukko commented on GitHub (Nov 14, 2024): this means that something else uses the 3001 port on your machine and cobalt can’t use it. try a different port or free up the 3001 port.
Author
Owner

@userlip commented on GitHub (Nov 14, 2024):

I actaully checked that before, and that is not the case:

netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.54:53 0.0.0.0:* LISTEN 1541/systemd-resolv
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 1541/systemd-resolv
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 1713/mysqld
tcp 0 0 0.0.0.0:10004 0.0.0.0:* LISTEN 1025878/php
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 3200917/docker-prox
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 1418825/redis-serve
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2068/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2068/nginx: master
tcp 0 0 127.0.0.1:8461 0.0.0.0:* LISTEN 1587/python3
tcp6 0 0 :::3306 :::* LISTEN 1713/mysqld
tcp6 0 0 :::443 :::* LISTEN 2068/nginx: master
tcp6 0 0 :::80 :::* LISTEN 2068/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1/init

@userlip commented on GitHub (Nov 14, 2024): I actaully checked that before, and that is not the case: netstat -nltp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.54:53 0.0.0.0:* LISTEN 1541/systemd-resolv tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 1541/systemd-resolv tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 1713/mysqld tcp 0 0 0.0.0.0:10004 0.0.0.0:* LISTEN 1025878/php tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 3200917/docker-prox tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 1418825/redis-serve tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2068/nginx: master tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2068/nginx: master tcp 0 0 127.0.0.1:8461 0.0.0.0:* LISTEN 1587/python3 tcp6 0 0 :::3306 :::* LISTEN 1713/mysqld tcp6 0 0 :::443 :::* LISTEN 2068/nginx: master tcp6 0 0 :::80 :::* LISTEN 2068/nginx: master tcp6 0 0 :::22 :::* LISTEN 1/init
Author
Owner

@dumbmoron commented on GitHub (Nov 14, 2024):

@userlip

Node.js v22.11.0

your node version is out of date

@dumbmoron commented on GitHub (Nov 14, 2024): @userlip > Node.js v22.11.0 your node version is out of date
Author
Owner

@dumbmoron commented on GitHub (Nov 14, 2024):

if you wish to use API_INSTANCE_COUNT, you need to use the latest node (as mentioned in docs):
160160704d/docs/run-an-instance.md (L81)

@dumbmoron commented on GitHub (Nov 14, 2024): if you wish to use API_INSTANCE_COUNT, you need to use the latest node (as mentioned in docs): https://github.com/imputnet/cobalt/blob/160160704d2acdd88784db3243e033d0b459c7df/docs/run-an-instance.md?plain=1#L81
Author
Owner

@userlip commented on GitHub (Nov 14, 2024):

yeap you are right, sorry for the troubles!

@userlip commented on GitHub (Nov 14, 2024): yeap you are right, sorry for the troubles!
Sign in to join this conversation.