tobiasehlert / teslamateapi

TeslaMateApi is a RESTful API to get data collected by self-hosted data logger TeslaMate in JSON
MIT License
89 stars 20 forks source link

password authentication failed for user "teslamate #252

Closed sultantariq closed 8 months ago

sultantariq commented 10 months ago

I am running TeslaMate Traefik setup in Docker with environment variables file (.env) and I am getting the below in the logs.

docker compose logs teslamateapi

teslamateapi_1  | 2023/10/29 11:38:10.956326 [info] TeslaMateApi running in debug mode.
teslamateapi_1  | 2023/10/29 11:38:10.965291 pq: password authentication failed for user "teslamate"
teslamateapi_1  | panic: pq: password authentication failed for user "teslamate"
teslamateapi_1  | 
teslamateapi_1  | goroutine 1 [running]:
teslamateapi_1  | log.Panic({0x1a3de60, 0x1, 0x1})
teslamateapi_1  |   /usr/local/go/src/log/log.go:432 +0x84
teslamateapi_1  | main.initDBconnection()
teslamateapi_1  |   /go/src/webserver.go:214 +0x3fc
teslamateapi_1  | main.main()
teslamateapi_1  |   /go/src/webserver.go:51 +0x1cc

Here is snippet from my docker compose file

services:
  teslamateapi:
    image: tobiasehlert/teslamateapi:latest
    restart: always
    depends_on:
      - database
    environment:
      - ENCRYPTION_KEY=${TM_ENCRYPTION_KEY}
      - DATABASE_USER=${TM_DB_USER}
      - DATABASE_PASS=${TM_DB_PASS}
      - DATABASE_NAME=${TM_DB_NAME}
      - DATABASE_HOST=database
      - MQTT_HOST=mosquitto
      - TZ=${TM_TZ}
      - DEBUG_MODE=true
    labels:
      - "traefik.enable=true"
      - "traefik.port=8080"
      - "traefik.http.middlewares.redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.teslamateapi-auth.basicauth.realm=teslamateapi"
      - "traefik.http.middlewares.teslamateapi-auth.basicauth.usersfile=/auth/.htpasswd"
      - "traefik.http.routers.teslamateapi-insecure.rule=Host(`${FQDN_TM}`)"
      - "traefik.http.routers.teslamateapi-insecure.middlewares=redirect"
      - "traefik.http.routers.teslamateapi.rule=Host(`${FQDN_TM}`) && (Path(`/api`) || PathPrefix(`/api/`))"
      - "traefik.http.routers.teslamateapi.entrypoints=websecure"
      - "traefik.http.routers.teslamateapi.middlewares=teslamateapi-auth"
      - "traefik.http.routers.teslamateapi.tls.certresolver=tmhttpchallenge"
    volumes:
      - ./.htpasswd:/auth/.htpasswd
      - ./.env:/.env

volumes:
  teslamate-db:
  teslamate-grafana-data:
  mosquitto-conf:
  mosquitto-data:
  node-red-data:
  teslamateapi:
tobiasehlert commented 9 months ago

Hi @sultantariq,

The database parameters should be identical to the teslamate service and then the connection should be established. Which release are you using on teslamateapi container? Could you also share the configuration of teslamate and postgresql services?

Regards, Tobias

tobiasehlert commented 8 months ago

hello @sultantariq,

Did your problem resolve or whats the status? :)

Kind regard, Tobias