Docker-composed vikunja frontend complains that it can't find backend, whereas backend is accessible. "user does not exist" error keeps popping up in API logs

I keep having problems getting this thing going and humbly request some assistance or at least insight. I’m using docker compose. I’ve tried this on two separate Docker hosts. I’m using the nginx proxy in front so that I can access API on the same address/port as the frontend. I’ve tried mysql and postgres.

In either case, I hit frontend and get this:

An error occurred:
AxiosError: Network Error

Please check if the api url is correct.

Whereas I can hit the API URL http://192.168.2.169/api/v1/info and get back what looks like good info:

{"version":"v0.21.0","frontend_url":"https://192.168.2.169/","motd":"","link_sharing_enabled":true,"max_file_size":"20MB","registration_enabled":true,"available_migrators":["vikunja-file","ticktick"],"task_attachments_enabled":true,"enabled_background_providers":["upload"],"totp_enabled":true,"legal":{"imprint_url":"","privacy_policy_url":""},"caldav_enabled":true,"auth":{"local":{"enabled":true},"openid_connect":{"enabled":false,"redirect_url":"https://192.168.2.169/auth/openid/","providers":null}},"email_reminders_enabled":true,"user_deletion_enabled":true,"task_comments_enabled":true}

API seems to be working fine.

In the logs keeps happening with every refresh of frontend:

vikinja-frontend-1  | 172.18.0.5 - - [04/Aug/2023:00:16:40 +0000] "GET / HTTP/1.0" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"
vikinja-proxy-1     | 192.168.1.16 - - [04/Aug/2023:00:16:40 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"
vikinja-api-1       | 2023-08-04T00:16:40.620853082Z: WEB 	▶ 172.18.0.5  GET 200 /api/v1/info 240.107µs - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
vikinja-proxy-1     | 192.168.1.16 - - [04/Aug/2023:00:16:40 +0000] "GET /api/v1/info HTTP/1.1" 200 595 "http://192.168.2.169/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"
vikinja-api-1       | 2023-08-04T00:16:40.630136291Z: ERROR	▶ v1/UserShow 0b5 User does not exist [user id: 1]
vikinja-api-1       | 2023-08-04T00:16:40.630205171Z: WEB 	▶ 172.18.0.5  GET 404 /api/v1/user 2.92875ms - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
vikinja-proxy-1     | 192.168.1.16 - - [04/Aug/2023:00:16:40 +0000] "GET /api/v1/user HTTP/1.1" 404 51 "http://192.168.2.169/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36" "-"

Specifically the ERROR ▶ v1/UserShow 0b5 User does not exist [user id: 1] is what seems to be the issue. I’m not at all sure what is going on here. This is a brand-new install. I’ve blown away the database folder many times prior to re-running, so I can’t say it’s like there’s a user there that shouldn’t be from a prior run.

Docker compose:

version: '3'

services:
  db:
    image: mariadb:10
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_ROOT_PASSWORD: supersecret
      MYSQL_USER: vikunja
      MYSQL_PASSWORD: secret
      MYSQL_DATABASE: vikunja
    volumes:
      - ./db:/var/lib/mysql
    restart: unless-stopped
  api:
    image: vikunja/api
    environment:
      VIKUNJA_DATABASE_HOST: db
      VIKUNJA_DATABASE_PASSWORD: secret
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: vikunja
      VIKUNJA_DATABASE_DATABASE: vikunja
      VIKUNJA_SERVICE_JWTSECRET: secretiest-secret-ever
      VIKUNJA_SERVICE_FRONTENDURL: https://192.168.2.169/
    volumes: 
      - ./files:/app/vikunja/files
    depends_on:
      - db
    restart: unless-stopped
  frontend:
    image: vikunja/frontend
    restart: unless-stopped
  proxy:
    image: nginx
    ports:
      - 80:80
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - api
      - frontend
    restart: unless-stopped

nginx.conf:

server {
    listen 80;

    location / {
        proxy_pass http://frontend:80;
    }

    location ~* ^/(api|dav|\.well-known)/ {
        proxy_pass http://api:3456;
        client_max_body_size 20M;
    }
}

Is there something that I’m doing wrong?

Again, I tried this with mariadb, postgres. I haven’t yet attempted a run to see if I can get frontend to find backend outside of using the proxy. I can confirm that they are all under the same docker network (as that’s what compose does)… I haven’t found any such errors like this, I’ve read the docs a few times. I’m flummoxed.

I just tried it again without the proxy, and it seemed to work, no problem.

On a whim, I installed again with the proxy, and it flopped. Then I tried it in an incognito window and it worked. With a proxy.

… I’ve more testing to do yet, but … something is working. I just don’t know what’s going on. Must be some caching thing.

Yeah, so far:

  • clear cache for that site in Brave on my phone - works
  • clear cache for that site in Brave on my Linux desktop - does NOT work
  • incognito in Brave on my Linux desktop - DOES work
  • firefox on Brave on my Linux desktop - works

:thinking:

Driving me nuts that I can’t get my desktop Brave to acknowledge it. Not even the “desktop app” seems to acknowledge it either though, still gives me the error.

I realize this is turning into more of an issue with my browser than anything, but this morning when I logged on to poke a bit further, suddenly it was loading in my Brave (without incognito). I broke the site again, broke access again. Closed the browser, re-opened, and it loaded. :man_shrugging:

So maybe this is the summary:

  • When it breaks (seems to be when doing something of a change with the database - getting a new one, restoring an old one even), frontend throws an error saying it can’t find backend
  • clear the cache for that site and/or restart the browser (or just use a different browser)
  • It should be OK.

If the frontend can’t find the api, there should be an error message in the logs about it, either in the browser (if it really can’t reach it) or in the api container (if there’s a problem with the /info endpoint making the frontend think there is no api at the url).

It’s really weird that the user does not exist. Are you 100% sure the user account exists? You can check this with vikunja user list.

In some cases this might be caused by an old token still saved in the browser, but if that’s the problem it should work in incognito.

Do you have a jwt secret configured in the api?