Cannot connect to database during setup

I’m trying to set up akkoma in docker through a reverse proxy, and when i get to the “Now we can actually run our migrations” section i get this error:

akko@LunarServer:~/akkoma$ ./docker-resources/manage.sh mix ecto.migrate
# this will recompile your files at the same time, since we changed the config
WARN[0000] /home/akko/akkoma/docker-compose.yml: `version` is obsolete 
[+] Creating 1/0
 ✔ Container akkoma-db-1  Running                                                                             0.0s 
==> restarter
Generated restarter app
==> pleroma
Compiling 603 files (.ex)
Compiling lib/pleroma/web/gettext.ex (it's taking more than 10s)

15:37:27.439 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.EnsureRePrepended is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.DropPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.TagPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.DirectMessageDisabledPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.NoPlaceholderTextPolicy is excluded from config descriptions, because does not implement `config_description/0` method.

15:37:27.448 [debug] Elixir.Pleroma.Web.ActivityPub.MRF.NoOpPolicy is excluded from config descriptions, because does not implement `config_description/0` method.
Generated pleroma app

15:37:29.414 [error] Postgrex.Protocol (#PID<0.4164.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

15:37:29.414 [error] Postgrex.Protocol (#PID<0.4163.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

15:37:32.099 [error] Postgrex.Protocol (#PID<0.4164.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

15:37:32.393 [error] Postgrex.Protocol (#PID<0.4163.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

15:37:37.893 [error] Postgrex.Protocol (#PID<0.4164.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

15:37:40.208 [error] Postgrex.Protocol (#PID<0.4163.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
a

I can’t find the issue, i’ve tried fixes from other simmilar problems but nothing has helped. Here is my caddyfile and docker-compose.yml, i dont think they would be causing the problem but better safe than sorry. Running debian 12, docker 26.0.0.
Caddyfile:

# default docker Caddyfile config for Akkoma
#
# Simple installation instructions:
# 1. Replace 'example.tld' with your instance's domain wherever it appears.

akko.moonc.at  {
  log {
    output file /var/log/caddy/akkoma.log
  }

  encode gzip

  reverse_proxy akkoma:4000
}

docker-compose.yml

version: "3.7"

services:
  db:
    image: akkoma-db:latest
    build: ./docker-resources/database
    shm_size: 4gb
    restart: unless-stopped
    user: ${DOCKER_USER}
    environment: {
      # This might seem insecure but is usually not a problem.
      # You should leave this at the "akkoma" default.
      # The DB is only reachable by containers in the same docker network,
      # and is not exposed to the open internet.
      #
      # If you do change this, remember to update "config.exs".
      POSTGRES_DB: akkoma,
      POSTGRES_USER: akkoma,
      POSTGRES_PASSWORD: akkoma,
    }
    env_file:
      - .env 
    volumes:
      - type: bind
        source: ./pgdata
        target: /var/lib/postgresql/data

  akkoma:
    image: akkoma:latest
    build: .
    restart: unless-stopped
    env_file:
      - .env
    links:
      - db
    ports: [
      # Uncomment/Change port mappings below as needed.
      # The left side is your host machine, the right one is the akkoma container.
      # You can prefix the left side with an ip.

      # Webserver (for reverse-proxies outside of docker)
      # If you use a dockerized proxy, you can leave this commented
      # and use a container link instead.
      "127.0.0.1:4000:4000",
    ]
    volumes:
      - .:/opt/akkoma

  # Uncomment the following if you want to use a reverse proxy
  proxy:
    image: caddy:2-alpine
    restart: unless-stopped
    links:
      - akkoma
    ports: [
       "443:443",
       "80:80"
    ]
    volumes:
      - ./docker-resources/Caddyfile:/etc/caddy/Caddyfile
      - ./caddy-data:/data
      - ./caddy-config:/config

that error message means you’ve got some config wrong somewhere!

it’s trying to connect to localhost, which naturally we don’t want - if you read the docs when you set up the config - you should have set the database host to db; you probably clicked past it

look in your config file and find the Repo config and set the host to db