listen udp 0.0.0.0:22000: bind: address already in use

On my homeserver I have this in my journalctl log

aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 failed: listen udp 0.0.0.0:22000: >
aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: Listen (BEP/quic): listen udp 0.0.0.0:22000: bind: address already in use
aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 failed: listen udp 0.0.0.0:22000: >
aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: Listen (BEP/quic): listen udp 0.0.0.0:22000: bind: address already in use
aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 failed: listen udp 0.0.0.0:22000: >
aug 14 18:49:42 vivo syncthing[838]: [RUXLX] INFO: Listen (BEP/quic): listen udp 0.0.0.0:22000: bind: address already in use
aug 14 18:48:35 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 failed: listen udp 0.0.0.0:22000: >
aug 14 18:48:35 vivo syncthing[838]: [RUXLX] INFO: Listen (BEP/quic): listen udp 0.0.0.0:22000: bind: address already in use
aug 14 18:48:35 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 failed: listen udp 0.0.0.0:22000: >
aug 14 18:48:35 vivo syncthing[838]: [RUXLX] INFO: Listen (BEP/quic): listen udp 0.0.0.0:22000: bind: address already in use
aug 14 18:48:35 vivo syncthing[838]: [RUXLX] INFO: listenerSupervisor@quic://0.0.0.0:22000: service quic://0.0.0.0:22000 
...

Since I saw that there multiple syncthing processes trying to bind to 22000 i thought it was duplicates:

❯ sudo lsof -i :22000
[sudo] password for einar:
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
syncthing 936 einar   12u  IPv6  29734      0t0  TCP *:22000 (LISTEN)
syncthing 936 einar   22u  IPv6 558752      0t0  TCP vivo.hemma:22000->x13.hemma:51646 (ESTABLISHED)
syncthing 980 einar   12u  IPv6  29721      0t0  TCP *:22000 (LISTEN)
syncthing 980 einar   18u  IPv6  29727      0t0  UDP *:22000

But when I look at the process tree it looks as if all processes share a common syncthing process ancestor?

❯ pstree -p | grep syncthing
           |-syncthing(838)-+-syncthing(936)-+-{syncthing}(937)
           |                |                |-{syncthing}(938)
           |                |                |-{syncthing}(939)
           |                |                |-{syncthing}(940)
           |                |                |-{syncthing}(941)
           |                |                |-{syncthing}(942)
           |                |                |-{syncthing}(943)
           |                |                |-{syncthing}(1006)
           |                |                |-{syncthing}(1033)
           |                |                |-{syncthing}(1056)
           |                |                `-{syncthing}(1057)
           |                |-{syncthing}(882)
           |                |-{syncthing}(885)
           |                |-{syncthing}(886)
           |                |-{syncthing}(887)
           |                |-{syncthing}(925)
           |                |-{syncthing}(934)
           |                |-{syncthing}(935)
           |                `-{syncthing}(2449)
           |              `-syncthing(968)-+-syncthing(980)-+-{syncthing}(982)
           |                               |                |-{syncthing}(983)
           |                               |                |-{syncthing}(984)
           |                               |                |-{syncthing}(985)
           |                               |                |-{syncthing}(986)
           |                               |                |-{syncthing}(987)
           |                               |                |-{syncthing}(999)
           |                               |                |-{syncthing}(1000)
           |                               |                |-{syncthing}(1055)
           |                               |                `-{syncthing}(3756)
           |                               |-{syncthing}(969)
           |                               |-{syncthing}(970)
           |                               |-{syncthing}(971)
           |                               |-{syncthing}(972)
           |                               |-{syncthing}(973)
           |                               |-{syncthing}(975)
           |                               |-{syncthing}(978)
           |                               `-{syncthing}(979)

Right now Syncthing seems to be working, but I had some issues the other way (which was the reason I was starting to look at logs).

How do you interpret these outputs? Are there duplicates or not?

(Edit: Here is some more info about my setup if it helps)

❯ cat /etc/systemd/system/syncthing@einar.service.d/override.conf
[Service]
Environment="STHOMEDIR=/home/einar/config/syncthing/vivo"
❯ sudo systemctl status syncthing@einar.service
● syncthing@einar.service - Syncthing - Open Source Continuous File Synchronization for einar
     Loaded: loaded (/lib/systemd/system/syncthing@.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/syncthing@einar.service.d
             └─override.conf
     Active: active (running) since Tue 2024-08-13 13:22:41 CEST; 1 day 5h ago
       Docs: man:syncthing(1)
   Main PID: 838 (syncthing)
      Tasks: 21 (limit: 18989)
     Memory: 134.0M
        CPU: 3min 30.418s
     CGroup: /system.slice/system-syncthing.slice/syncthing@einar.service
             ├─838 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0
             └─936 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0

You’re looking at threads and not processes, so it’s confusing. There should be two processes, one managing the other, with only one of them listening on network ports.

@calmh Thanks for replying. I added some more info in the first post, regarding my setup, if it helps. I am not sure how to interpret you answer though, is there another command I can run that would bring clarity to the situation?

❯ netstat -nlp | grep 22000
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::22000                :::*                    LISTEN      980/syncthing
tcp6       0      0 :::22000                :::*                    LISTEN      936/syncthing
udp6       0      0 :::22000                :::*                                980/syncthing
🌐 ~
❯ ps aux | rg syncthing
einar        838  0.0  0.1 1250680 18704 ?       Ssl  aug13   0:08 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0
einar        936  0.1  0.3 1318716 51688 ?       SNl  aug13   3:22 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0
einar        968  0.0  0.1 1249784 16608 ?       Ssl  aug13   0:04 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0
einar        980  0.1  0.1 1251704 30600 ?       SNl  aug13   2:01 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0

Duplicates, yes?

On my laptop I only have

❯ ps aux | rg syncthing
einar        374  0.0  0.1 1249464 20408 ?       Ssl  17:59   0:00 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0
einar        431  0.1  0.3 1252472 51768 ?       SNl  17:59   0:05 /usr/bin/syncthing serve --no-browser --no-restart --logflags=0

That looks like two separate instances, yes, presumably with different setup and config directory.

I found the problem, I had synchting both configured as a system-level service (for a user?) and as a user-level service in systemd.

I disabled the user-level service.

Thanks!

2 Likes