Skip to content

aw-qt-0^20240903 always fails to locate aw-server on first invocation after server boot. #113

Closed

Description

@beedell-roke

The Reproduction Method 1

  1. #!/usr/bin/env sh
    aw-server && \
    aw-qt
  2. Image

  3. Restart

Its Consequence

2025-08-12 10:55:24 [WARNING]: Tried to stop module aw-server, but it wasn't running  (aw_qt.manager:185)
2025-08-12 10:55:55 [INFO ]: Starting module aw-server  (aw_qt.manager:148)
[2025-08-12 10:55:55][INFO][aw_server]: Using DB at path "/home/RokeJulianLockhart/.local/share/activitywatch/aw-server-rust/sqlite.db"
[2025-08-12 10:55:55][INFO][aw_server]: Using aw-webui assets at path None
[2025-08-12 10:55:55][INFO][aw_server::endpoints]: Starting aw-server-rust at 127.0.0.1:5600
Error: Bind(Os { code: 98, kind: AddrInUse, message: "Address already in use" })

My Diagnosis

Could it be because the aw-server option comes disabled (that is, by default) in the System Tray icon's QMenu's “Modules” QAction?

My Environment

  1. The Server And Client

    1. #!/usr/bin/env sh
      rpm -qa *-aw*
    2. python3-aw-core-0.5.17-3.fc42.noarch
      python3-aw-client-0.5.14-2.fc42.noarch
      nodejs-aw-webui-0^20250507.9259df7-2.fc42.noarch
      python3-aw-qt-0^20240903.43864b2-2.fc42.noarch
  2. The OS And DE

    Details

    1. #!/usr/bin/env sh
      fastfetch -l none
    2. OS: Fedora Linux 42 (KDE Plasma Desktop Edition) x86_64
      Host: Laptop 16 (AMD Ryzen 7040 Series) (A7)
      Kernel: Linux 6.15.9-201.fc42.x86_64
      Uptime: 1 hour, 1 min
      Packages: 2926 (rpm), 23 (flatpak)
      Shell: bash 5.2.37
      Display (BOE0BC9): 2560x1600 @ 165 Hz (as 1706x1066) in 16" [Built-in]
      DE: KDE Plasma 6.4.4
      WM: KWin (Wayland)
      WM Theme: Breeze
      Theme: Breeze (Dark) [Qt], Breeze-Dark [GTK3/4]
      Icons: breeze-dark [Qt], breeze-dark [GTK3/4]
      Font: Monospace (10pt) [Qt], Monospace (10pt) [GTK3/4]
      Cursor: breeze (24px)
      Terminal: konsole 25.4.3
      CPU: AMD Ryzen 7 7840HS (16) @ 5.14 GHz
      GPU: AMD Radeon 780M Graphics [Integrated]
      Memory: 11.11 GiB / 30.65 GiB (36%)
      Swap: 0 B / 8.00 GiB (0%)
      Disk (/): 190.47 GiB / 929.91 GiB (20%) - btrfs
      Local IP (wlp1s0): 192.168.1.219/24
      Battery (FRANDBA): 87% [Charging, AC Connected]
      Locale: en_GB.UTF-8

Footnotes

  1. discussions/1168#discussioncomment-14080795 ↩

Activity

  1. addy-zero commented on Oct 28, 2025

    @addy-zero

    Similar error.
    aw-server crashes almost everytime during startup (Linux Mint).

    Contents of 'Show Details':

    2025-10-28 14:04:35 [INFO ]: Using storage method: peewee (aw_server.main:33)
    2025-10-28 14:04:35 [INFO ]: Starting up... (aw_server.main:41)
    2025-10-28 14:04:35 [INFO ]: Using database file: /home/adizcode/.local/share/activitywatch/aw-server/peewee-sqlite.v2.db (aw_datastore.storages.peewee:150)

  2. TimeToBuildBob commented on Feb 27, 2026

    @TimeToBuildBob
    Contributor

    This is expected behavior when you run aw-server manually before aw-qt. Here's what happens:

    1. aw-server && aw-qt starts aw-server as a standalone process (binds to port 5600)
    2. When aw-qt launches, it tries to start its own aw-server module — but port 5600 is already taken
    3. The "Address already in use" error is the result

    The fix: Don't run aw-server separately. aw-qt manages aw-server as a subprocess — just run aw-qt alone:

    aw-qt

    The "Modules" menu in the tray icon shows which modules aw-qt is managing. If aw-server shows as disabled there, it means aw-qt detected that something is already listening on port 5600 and skipped launching its own instance.

    If you need to run aw-server standalone (e.g., aw-server-rust while aw-qt is configured for the Python server), you should disable the server module in aw-qt's config (aw-qt.toml) to avoid the conflict.

  3. beedell-roke commented on Feb 27, 2026

    @beedell-roke
    Author

    If I understand correctly, @TimeToBuildBob, is the problem is two-fold? Specifically:

    1. aw-server isn't being invoked by default by the Qt client, because something has taken the server's port, and the Qt client has not been designed to choose another port, if 5 000 is unavailable; and:

    2. If the user attempts to bypass this, by manually invoking aw-server, which can automatically choose a different port when invoked outside of the Qt client, the Qt client does not identify the invoked server instance, albeit merely until it is reinvoked.

  4. TimeToBuildBob commented on Feb 27, 2026

    @TimeToBuildBob
    Contributor

    Mostly correct on point 1, but point 2 has a misconception worth clarifying:

    Point 1 ✓: aw-qt always tries to start aw-server on port 5600. It doesn't have logic to detect a port conflict upfront — it just tries to bind and fails. There's no alternative-port fallback.

    Point 2 — the standalone aw-server also uses port 5600 by default. It doesn't automatically choose a different port. Both the standalone invocation and aw-qt's managed instance compete for the same port.

    The flow in your case:

    1. aw-server starts → binds port 5600 ✓
    2. aw-qt starts → tries to launch its own aw-server on 5600 → fails with "Address already in use"
    3. After clicking "Restart" → aw-qt detects that 5600 is already responding and uses that existing server

    So the "Restart" essentially makes aw-qt re-probe the port without trying to manage a subprocess. It works, but the whole issue is avoided by just running aw-qt directly — it starts aw-server for you.

  5. beedell-roke commented on Feb 28, 2026

    @beedell-roke
    Author

    @TimeToBuildBob, that's a reasonable workaround, but aren't there reasons that the server would already be running without the client, or are they never separately invoked?

  6. TimeToBuildBob commented on Feb 28, 2026

    @TimeToBuildBob
    Contributor

    Good question. There are a few scenarios where aw-server might already be running:

    1. Systemd service — some users set up aw-server as a systemd unit (common on headless Linux servers for remote tracking)
    2. Docker/container — running aw-server in a container while using aw-qt on the host
    3. Manual start during debugging — starting aw-server directly to check logs, then forgetting it's running

    But for the normal desktop use case: no, you'd just run aw-qt and it handles everything. The only real "bug" here is that aw-qt's error message on port conflict is confusing — it should detect an existing server and connect to it on first try, rather than requiring a manual "Restart" click.

  7. TimeToBuildBob commented on Mar 11, 2026

    @TimeToBuildBob
    Contributor

    PR submitted: #123

    Implements pre-startup detection of existing aw-server instances. When aw-server is already running (systemd, Docker, manual start), aw-qt now connects to it automatically instead of failing and requiring a manual Restart click.

  8. TimeToBuildBob commented on Mar 16, 2026

    @TimeToBuildBob
    Contributor

    This is addressed by #123 (currently open, pending review). The PR adds a pre-startup check that probes the server port before launching — if a server is already running (systemd, Docker, manual), it marks the module as 'external' and skips launching its own subprocess, avoiding the bind error entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions