Keep getting error "server does not support SSL, but SSL was required"

I’m trying to get a django project up and running with postgres and I’m using the postgres:latest service. I’ve set sslmode to disable in django

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': config.db_config.name,
        'USER': config.db_config.username,
        'PASSWORD': config.db_config.password,
        'HOST': config.db_config.host,
        'PORT': config.db_config.port,
        'OPTIONS': {'sslmode': config.db_config.ssl_mode} # <- this is set to disable
    }
}

However I keep getting the error “server does not support SSL, but SSL was required”. Do I need to disable ssl on the postgres service? If so, how would I do that?

seeing: “server does not support SSL, but SSL was required”
expected: succesful run
gitlab version: GitLab Enterprise Edition 14.2.0-pre
runner version: ???

.gitlab-ci.yml

# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python
image: python:3.6.9

services:
  - postgres:latest

stages:
  - setup
  # - build
  - test

variables:
  env: dev
  POSTGRES_DB: ci
  POSTGRES_USER: postgres
  POSTGRES_PASSWORD: postgres

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
# services:
#  - postgres:latest
#
#variables:
#  POSTGRES_DB: database_name

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
    - ~/.cache/pip/

# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
  # - wget https://github.com/mozilla/geckodriver/releases/download/v0.19.0/geckodriver-v0.19.0-linux64.tar.gz; mkdir geckodriver; tar -xzf geckodriver-v0.19.0-linux64.tar.gz -C geckodriver; export PATH=$PATH:$PWD/geckodriver;
  - python -V  # Print out python version for debugging
  - pip install -r requirements.txt
  # Uncomment next line if your Django app needs a JS runtime:
  # - apt-get update -q && apt-get install nodejs -yqq


# To get Django tests to work you may need to create a settings file using
# the following DATABASES:
#
# DATABASES = {
#     'default': {
#        'ENGINE': 'django.db.backends.postgresql_psycopg2',
#        'NAME': 'ci',
#        'USER': 'postgres',
#        'PASSWORD': 'postgres',
#        'HOST': 'postgres',
#        'PORT': '5432',
#    },
# }
#
# and then adding `--settings app.settings.ci` (or similar) to the test command

setup:
  stage: setup
  script:
    - echo "Setting Up"

#build:
#  stage: build
#  script:
#    - echo "Building and install deps"
#  artifacts:
#    paths:
#      - ./

test:
  # stage: test
  variables:
    DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/ci"
  #  variables:
#    DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
  script:
    # - wget https://github.com/mozilla/geckodriver/releases/download/v0.19.0/geckodriver-v0.19.0-linux64.tar.gz; mkdir geckodriver; tar -xzf geckodriver-v0.19.0-linux64.tar.gz -C geckodriver; export PATH=$PATH:$PWD/geckodriver;
    # - pip install -r requirements.txt
    # - python manage.py makemigrations
    # - python manage.py migrate
    - python manage.py test --tag=unit

after_script:
  - python --version
  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
    • docs: Using PostgreSQL | GitLab
    • added POSTGRES_HOST_AUTH_METHOD: trust env variable
    • set sslmode to disabled in django server