> ## Documentation Index
> Fetch the complete documentation index at: https://koonj-docs.appsthatmatter.uk/llms.txt
> Use this file to discover all available pages before exploring further.

# Operations and troubleshooting

> Configure notification delivery, apply database migrations, and troubleshoot a Koonj deployment.

## Run the notification worker

The API records pending notifications in PostgreSQL. The worker reads them, publishes delivery IDs to RabbitMQ, and sends SMTP or webhook notifications. Packaged Docker starts the worker automatically.

| Settings | What to configure |
| - | - |
| Database | Set `KOONJ_DB_URL`, `KOONJ_DB_USERNAME`, and `KOONJ_DB_PASSWORD` to the API's database. |
| RabbitMQ | Set `KOONJ_RABBITMQ_HOST`, `KOONJ_RABBITMQ_PORT`, `KOONJ_RABBITMQ_USERNAME`, `KOONJ_RABBITMQ_PASSWORD`, and `KOONJ_RABBITMQ_VHOST`. Enable `KOONJ_RABBITMQ_SSL` for AMQP over TLS. |
| SMTP defaults | Set `KOONJ_MAIL_HOST`, `KOONJ_MAIL_PORT`, and `KOONJ_MAIL_FROM`. Configure `KOONJ_MAIL_TLS` and relay credentials for your provider. |
| Capacity and licensing | Set `KOONJ_QUOTA_CATALOGED_FILES`, `KOONJ_QUOTA_STORAGE_CONNECTIONS`, `KOONJ_QUOTA_TRANSFER_CONCURRENCY`, and optional license dates `KOONJ_LICENSE_EXPIRES_AT` and `KOONJ_LICENSE_GRACE_ENDS_AT`. A quota of `0` disables its check. |

In **Integration → Notifications & Alerts**, test a channel and check its delivery history. Check worker logs with `docker compose logs koonj-notification-worker`.

## Upgrade an existing database

1. Stop accepting jobs and let active transfers finish. Back up PostgreSQL and the configuration needed to recover storage credentials. Stop the API, transfer workers, and notification workers.
2. Check the release notes and the deployment guide shipped with your version for migration requirements. Test the upgrade against a restored copy of PostgreSQL, with access to the credential wrapping keys. With `KOONJ_DDL_AUTO=validate` or `none`, apply the migrations supplied for the release before restarting.
3. Start the upgraded API before the transfer and notification workers. Check project access and run a representative scan, archive, and recall before resuming normal traffic.

## Production configuration

Serve the console and Keycloak over HTTPS. Limit network access to PostgreSQL, RabbitMQ, and the Keycloak administration console. Restrict access to `.env` and to the database, which stores configured storage and notification credentials. Use dedicated roots and buckets for separate projects. Use Keycloak production mode and review whether to allow self-registration.

The packaged UI binds one host port. To run multiple UI instances, deploy them behind a load balancer with distinct host ports or hosts. Budget PostgreSQL connections across API and worker instances when tuning `KOONJ_DB_POOL_SIZE` and `KOONJ_NOTIFICATION_DB_POOL_SIZE`.

## Troubleshoot common failures

| Symptom | What to check |
| - | - |
| Service unhealthy | Run `docker compose ps` and `docker compose logs <service-name>`. |
| API cannot connect to PostgreSQL | Check `KOONJ_DB_URL`, the database login, and network access. Check schema migration status if the API or worker runs in validation mode. |
| Sign-in loop or API returns `401` | Compare `keycloakUrl`, the realm issuer, redirect URLs, and the token audience. Verify that the API can reach the signing-key endpoint and that system clocks agree. |
| API returns `403` | Check the user's realm role, effective permissions, project membership, and job ownership where applicable. |
| Scan cannot see files | Use a path visible to the API process or inside its container, then check filesystem permissions and the connection test. |
| Notification missing | Check the channel test, rule filters, worker logs, RabbitMQ connectivity, and delivery history. For job email, check the recipient's verified sign-in address and notification preferences. |
| Recall is waiting | Check the job or gateway logs. Cold S3 objects may need a provider restore before their contents can be read. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.