# \[SSL: TLSV1\_ALERT\_PROTOCOL\_VERSION\] tlsv1 alert protocol version

**URL:** <https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775>\
**Category:** Deployments\
**Tags:** docker\
**Created:** [June 7, 2019, 7:05pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775 "2019-06-07T19:05:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 7, 2019, 7:05pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/1 "2019-06-07T19:05:01Z")

</div>

I have been battling with this issue and will need help.  
So I am using django-cookiecutter + docker for the project.  
The app runs ok after deploying the docker container to the server.

But when trying to push changes through cirlceci, the I get this error at the deploy phase

```auto
Creating CA: /home/circleci/.docker/machine/certs/ca.pem
Creating client certificate: /home/circleci/.docker/machine/certs/cert.pem
Running pre-create checks...
Creating machine...
(production) Importing SSH key...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env production
Building postgres
ERROR: SSL error: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)
Exited with code 1

```

Update: config.xml

```auto
jobs:
  build:
    machine: true
    working_directory: ~/app_api
    steps:
      - checkout
      - run:
          name: Run tests
          command: |
            docker-compose -f local.yml up -d
            docker-compose -f local.yml run django python manage.py help
            docker-compose -f local.yml run django pytest
  deploy:
    machine: true
    working_directory: ~/app_api
    steps:
      - checkout
      - add_ssh_keys:
          fingerprints: 
            **:** : **:** : **:** : **:** : **:** : **:** : **:** : **:**
      - run:
          name: Deploy Master to Digital Ocean
          command: |
            cp ./id_rsa.pub ~/.ssh
            ls -al ~/.ssh
            base=https://github.com/docker/machine/releases/download/v0.14.0 &&
            curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
            sudo install /tmp/docker-machine /usr/local/bin/docker-machine
            mkdir -p .envs/.production
            echo POSTGRES_HOST=$POSTGRES_HOST >> .envs/.production/.postgres
            echo REDIS_URL=$REDIS_URL >> .envs/.production/.django
            ...
            docker-machine create --driver generic --generic-ip-address 1 **.2**.1 **.** 7 --generic-ssh-key ~/.ssh/id_rsa production
            eval "$(docker-machine env production)"
            docker-compose -f production.yml build
            docker-compose -f production.yml up -d

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build

```

production.yml

```auto
version: '3'

volumes:
  production_postgres_data: {}
  production_postgres_data_backups: {}
  production_traefik: {}

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    image: app_api_production_django
    depends_on:
      - postgres
      - redis
    env_file:
      - ./.envs/.production/.django
      - ./.envs/.production/.postgres
    command: /start

  postgres:
    build:
      context: .
      dockerfile: ./compose/production/postgres/Dockerfile
    image: vest_api_production_postgres
    volumes:
      - production_postgres_data:/var/lib/postgresql/data
      - production_postgres_data_backups:/backups
    env_file:
      - ./.envs/.production/.postgres

  traefik:
    build:
      context: .
      dockerfile: ./compose/production/traefik/Dockerfile
    image: app_api_production_traefik
    depends_on:
      - django
    volumes:
      - production_traefik:/etc/traefik/acme
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"

  redis:
    image: redis:3.2

  celeryworker:
    <<: *django
    image: app_api_production_celeryworker
    command: /start-celeryworker

  celerybeat:
    <<: *django
    image: app_api_production_celerybeat
    command: /start-celerybeat

  flower:
    <<: *django
    image: app_api_production_flower
    ports:
      - "5555:5555"
    command: /start-flower
  awscli:
    build:
      context: .
      dockerfile: ./compose/production/aws/Dockerfile
    env_file:
      - ./.envs/.production/.django
    volumes:
      - production_postgres_data_backups:/backups

```

Any idea why this happens?

---

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 8, 2019, 5:16am UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/3 "2019-06-08T05:16:36Z")

</div>

done, thanks!

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 8, 2019, 8:54pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/4 "2019-06-08T20:54:57Z")

</div>

OK, so I think the issue is in your `docker-compose -f production.yml build`. Have you traced what line it is getting stuck on in your `production.yml`? If you want readers to take a view on that, you’d need to show that.

---

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 8, 2019, 9:22pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/5 "2019-06-08T21:22:46Z")

</div>

I have updated it with the a more complete error trace and the `production.yml` file

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 8, 2019, 9:26pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/6 "2019-06-08T21:26:37Z")

</div>

Ah, so you are not running from an image directly from Docker Hub - you are rolling your own in `./compose/production/postgres/Dockerfile`. I assume the console output shows you are still in a build phase rather than bringing it up. If so, let’s see the `Dockerfile`… 😉

Also, please indicate what line in the Dockerfile it is getting stuck on.

---

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 8, 2019, 9:37pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/7 "2019-06-08T21:37:20Z")

</div>

this is the dockerfile, can’t seem to figure our what line exactly it gets stuck on

django/Dockerfile

```auto

FROM python:3.6-alpine

ENV PYTHONUNBUFFERED 1

RUN apk update \
  # psycopg2 dependencies
  && apk add --virtual build-deps gcc python3-dev musl-dev \
  && apk add postgresql-dev \
  && apk add ca-certificates \
  # Pillow dependencies
  && apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
  # CFFI dependencies
  && apk add libffi-dev py-cffi

RUN addgroup -S django \
    && adduser -S -G django django

# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/production.txt \
    && rm -rf /requirements

COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r//' /entrypoint
RUN chmod +x /entrypoint
RUN chown django /entrypoint

COPY ./compose/production/django/start /start
RUN sed -i 's/\r//' /start
RUN chmod +x /start
RUN chown django /start
COPY ./compose/production/django/celery/worker/start /start-celeryworker
RUN sed -i 's/\r//' /start-celeryworker
RUN chmod +x /start-celeryworker
RUN chown django /start-celeryworker

COPY ./compose/production/django/celery/beat/start /start-celerybeat
RUN sed -i 's/\r//' /start-celerybeat
RUN chmod +x /start-celerybeat
RUN chown django /start-celerybeat

COPY ./compose/production/django/celery/flower/start /start-flower
RUN sed -i 's/\r//' /start-flower
RUN chmod +x /start-flower
COPY . /app

RUN chown -R django /app

USER django

WORKDIR /app

ENTRYPOINT ["/entrypoint"]

```

entrypoint

```auto
#!/bin/sh

set -o errexit
set -o pipefail
set -o nounset

# N.B. If only .env files supported variable expansion...
export CELERY_BROKER_URL="${REDIS_URL}"

if [-z "${POSTGRES_USER}"]; then
    base_postgres_image_default_user='postgres'
    export POSTGRES_USER="${base_postgres_image_default_user}"
fi
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"

postgres_ready() {
python << END
import sys

import psycopg2

try:
    psycopg2.connect(
        dbname="${POSTGRES_DB}",
        user="${POSTGRES_USER}",
        password="${POSTGRES_PASSWORD}",
        host="${POSTGRES_HOST}",
        port="${POSTGRES_PORT}",
    )
except psycopg2.OperationalError:
    sys.exit(-1)
sys.exit(0)

END
}
until postgres_ready; do
  >&2 echo 'Waiting for PostgreSQL to become available...'
  sleep 1
done
>&2 echo 'PostgreSQL is available'

exec "$@"

```

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 8, 2019, 9:39pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/8 "2019-06-08T21:39:49Z")

</div>

Cool, add `--no-cache` to your `docker-compose build` and see what gets printed to the console. I assume it is not finishing the build, and it is not getting to the `docker-compose up`. Paste the new `build` output here if you wish.

---

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 8, 2019, 9:41pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/9 "2019-06-08T21:41:55Z")

</div>

> [@halfer](#):
>
> –no-cache

on ok it, thanks

---

<div class="post-metadata">

**Author:** ![b3h3rkz](https://avatars.discourse-cdn.com/v4/letter/b/7cd45c/32.png) [@b3h3rkz](https://discuss.circleci.com/u/b3h3rkz)\
**Post date:** [June 8, 2019, 10:27pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/10 "2019-06-08T22:27:50Z")

</div>

same exact issue.  
do you think rebuilding the whole image from scratch might help?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [June 8, 2019, 11:59pm UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/11 "2019-06-08T23:59:28Z")

</div>

> [@b3h3rkz](#):
>
> same exact issue.

No, you misunderstood what I was asking you to do. The flag I recommended can be used to build this image from scratch, so that you can see the point where it fails more clearly, without the cached layers potentially obfuscating the issue. I was not expecting it to fix the problem.

If you would like help on that, you will need to run that command, with that flag, and show the _full_ build output here. Or, you can examine the output yourself, and add a note here to explain what step in the Dockerfile it fails on.

---

<div class="post-metadata">

**Author:** ![testxq2020](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@testxq2020](https://discuss.circleci.com/u/testxq2020)\
**Post date:** [October 13, 2020, 8:52am UTC](https://discuss.circleci.com/t/ssl-tlsv1-alert-protocol-version-tlsv1-alert-protocol-version/30775/12 "2020-10-13T08:52:50Z")

</div>

I am getting this issue on running docker-compose.yaml. Can you please let me know what is the resolution for this issue?

> **[CircleCI](https://app.circleci.com/pipelines/github/testxq2020/testproject-circleci/54/workflows/d1622391-cd79-4a20-a623-f3dd26bca1ea/jobs/55)**

Thanks
