Gitlab CI cannot connect to Postgres service - Rails 7.1.2 | Ruby 3.2.2

My Gitlab CI always fail with the below error message:

 PG::ConnectionBad:
      #   could not connect to server: Connection refused
      #   	Is the server running on host "::1" and accepting
      #   	TCP/IP connections on port 5432?
      #   could not connect to server: Connection refused
      #   	Is the server running on host "127.0.0.1" and accepting
      #   	TCP/IP connections on port 5432?
      #   /cache/ruby/3.2.0/gems/pg-1.5.4/lib/pg/connection.rb:696:in `async_connect_or_reset'

Here is the setup of my .gitlab-ci.yml

stages:
  - test

.base:
  image: ruby:3.2.2-bullseye

  cache:
    paths:
      - node_modules

  services:
    - redis:latest

  variables:
    BUNDLE_PATH: vendor/bundle
    SAFELIST_IP: ""
    REDIS_URL: redis://redis:6379
    RATIONING_PUBSUB_REDIS_URL: redis://redis:6379
    SECRET_KEY_BASE: $SECRET_KEY_BASE

Backend Tests:
  stage: test
  extends: .base
  services:
    - postgres:latest
  variables:
    RAILS_ENV: "test"
    POSTGRES_DB: "terminal_test"
    POSTGRES_USER: postgres
    POSTGRES_PASSWORD: password
    POSTGRES_HOST: postgres
    DB_USERNAME: postgres
    DB_PASSWORD: password
    DB_HOST: postgres
    POSTGRES_HOST_AUTH_METHOD: trust
  script:
    - bin/setup_ci
    - cp .env.sample .env
    - bundle config set path '/cache'
    - bundle install
    - bundle exec rake db:create RAILS_ENV=test
    - bundle exec rspec

And here is the database.yml

test:
  <<: *default
  database: <%= ENV.fetch("POSTGRES_DB") { "terminal_test" } %>
  user: <%= ENV.fetch("POSTGRES_USER") { nil } %>
  password: <%= ENV.fetch("POSTGRES_PASSWORD") { "" } %>
  host: <%= ENV.fetch("POSTGRES_HOST") { "localhost" } %>

Thank you for taking a look at the issue.

Try adding thisline into variables:
POSTGRES_HOST_AUTH_METHOD: trust