> For the complete documentation index, see [llms.txt](https://docs.kiloiot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/operations/operations-and-troubleshooting.md).

# Betrieb und Fehlersuche

KiloCenter-Betrieb — Health-Endpunkte für KC-Core, KC-Gateway, KC-Identity, häufige Startprobleme, Diagnose.

### Ziel

Führen Sie wiederholbare Prüfungen für Startprobleme, Verbindungsprobleme und Fehler im Nachrichtenfluss aus.

### Gesundheitsprüfungen

Von `kilocenter-modules/`:

```bash
# KC-Core-Gesundheitsprüfung
curl -s http://localhost:8086/health

# KC-Gateway-Gesundheitsprüfung
curl -s http://localhost:8087/health

# gRPC-Dienst-Gesundheitsprüfung
grpcurl -plaintext localhost:9090 grpc.health.v1.Health/Check

# Alle Containerdienste
docker compose ps
```

### Port-Prüfungen

Stellen Sie sicher, dass alle erwarteten Dienste lauschen:

```bash
lsof -i :80     # KC-Web (Containermodus)
lsof -i :9090   # KC-Gateway (gRPC-Web)
lsof -i :8086   # KC-Core-Gesundheitsprüfung
lsof -i :8087   # KC-Gateway-Gesundheitsprüfung
lsof -i :5000   # BSSCI
lsof -i :5001   # SCACI
lsof -i :50051  # internes gRPC von KC-Core
lsof -i :5433   # PostgreSQL (Docker)
lsof -i :6379   # Redis
lsof -i :1883   # MQTT (falls aktiviert)
```

Port 5173 wird nur im Quell-Entwicklermodus verwendet (Vite-Entwicklungsserver).

### Operationen im Containermodus

```bash
# Protokolle für einen Dienst anzeigen
docker compose logs -f kilocenter
docker compose logs -f kc-gateway
docker compose logs -f kc-web

# Einen einzelnen Dienst neu starten
docker compose restart kilocenter

# Alle Dienstzustände prüfen
docker compose ps
```

### Logdateien (Quell-Entwicklermodus)

Alle Dienstprotokolle werden geschrieben nach `kilocenter-modules/logs/runtime/`:

```bash
# KC-Core-Logs (BSSCI-Aktivität, Nachrichtenverarbeitung)
tail -f logs/runtime/kc-core.log

# KC-Gateway-Logs (API-Proxy-Aktivität)
tail -f logs/runtime/kc-gateway.log

# KC-Web-Logs (Frontend-Entwicklungsserver)
tail -f logs/runtime/kc-web.log

# Nach Fehlern in allen Logs suchen
grep -E "ERROR|FATAL" logs/runtime/*.log
```

### Prüfung der Datenbankverbindung

Stellen Sie sicher, dass PostgreSQL erreichbar ist:

```bash
PGPASSWORD=changeme psql -U kilocenter -h localhost -p 5433 -d kilocenter -c "SELECT 1;"
```

Verwenden Sie Port `5432` anstelle von `5433` wenn PostgreSQL direkt auf dem Host ausgeführt wird (nicht via Docker).

### Dienste stoppen

**Containermodus:**

```bash
docker compose down
```

**Quell-Entwicklermodus:**

```bash
./stop-all-services.sh

# Auch Infrastruktur-Container stoppen
docker compose stop postgres redis mosquitto
```

### Häufige Probleme

| Symptom                                         | Ursache                                                         | Lösung                                                                                        |
| ----------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `dial tcp ...5432: Verbindungsaufbau abgelehnt` | PostgreSQL-Port stimmt nicht überein                            | Verwenden Sie `5433` für Docker, `5432` für die Host-Installation                             |
| KC-Web zeigt gRPC-Fehler an                     | KC-Gateway läuft nicht oder falscher Port                       | Überprüfen Sie KC-Gateway auf Port 9090; prüfen Sie die nginx-Konfiguration im Containermodus |
| `Zugriff verweigert /var/run/docker.sock`       | Mitgliedschaft in der Docker-Gruppe                             | Ausführen `sudo usermod -aG docker $USER` und erneut anmelden                                 |
| `TLS-Zertifikat konnte nicht geladen werden`    | Zertifikatsdateien fehlen oder sind ungültig                    | Ausführen `certgen` -- siehe Installation                                                     |
| Basisstation verbindet sich nicht               | BSSCI-Port 5000 lauscht nicht                                   | Prüfen Sie, ob KC-Core gestartet ist und TLS-Zertifikate konfiguriert sind                    |
| SCACI akzeptiert keine Verbindungen             | Fehlender `scaci_tls` Konfigurationsblock                       | Prüfe `config/config.docker.yaml` hat `scaci_host` und `scaci_tls` Abschnitt                  |
| KC-Web gibt bei gRPC-Aufrufen 502 zurück        | nginx kann nicht erreichen `kc-gateway:9090`                    | Prüfen Sie `kc-gateway` ist gesund: `docker compose ps`                                       |
| `start-dev.sh` schlägt fehl                     | Abhängigkeiten laufen nicht                                     | Starten `docker compose up -d postgres redis mosquitto` zuerst                                |
| Bun nicht gefunden                              | Bun-Runtime nicht installiert                                   | Bun installieren: `curl -fsSL https://bun.sh/install \| bash`                                 |
| KC-Web lädt, zeigt aber keine Daten an          | KC-Core läuft nicht oder es sind keine Basisstationen verbunden | Prüfen Sie die Health-Endpunkte und den Status der Basisstation                               |

### Wiederherstellungssequenz

**Containermodus:**

1. Alle Dienste stoppen: `docker compose down`
2. Alle Dienste starten: `docker compose up -d`
3. Führen Sie Gesundheitsprüfungen aus (siehe oben)

**Quell-Entwicklermodus:**

1. Alle Dienste stoppen: `./stop-all-services.sh`
2. Infrastruktur neu starten: `docker compose restart postgres redis mosquitto`
3. Dienste starten: `./start-dev.sh`
4. Führen Sie Gesundheitsprüfungen aus (siehe oben)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kiloiot.io/kilo-docs-de/kilo-center/kilo-mioty-service-center/operations/operations-and-troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
