# Error in starting traefik with https

**URL:** <https://community.traefik.io/t/error-in-starting-traefik-with-https/3162>\
**Category:** Traefik v2\
**Tags:** file, docker\
**Created:** [November 26, 2019, 12:18am UTC](https://community.traefik.io/t/error-in-starting-traefik-with-https/3162 "2019-11-26T00:18:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sisuser1987](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@sisuser1987](https://community.traefik.io/u/sisuser1987)\
**Post date:** [November 26, 2019, 12:18am UTC](https://community.traefik.io/t/error-in-starting-traefik-with-https/3162/1 "2019-11-26T00:18:47Z")

</div>

Hi,  
I had a working dev application with http only of traefik and a microservice running in docker-compose. Now I am changing it to https. I use [mkcert](https://mkcert.dev/) to generate a couple of mock certficates for dev.localhost.

Docker-compose

```auto
version: '3'

services:
  traefik:
    image: traefik:v2.0
    command: 
      - --entryPoints.web.address=:80
      - --entryPoints.web-secure.address=:443
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.tls.cert=/etc/certs/dev.localhost+4.pem
      - --providers.docker.tls.key=/etc/certs/dev.localhost+4-key.pem  
      - --accesslog=true 
      - --log.level=DEBUG
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock    
      - ./certs:/etc/certs
    labels:
      - "traefik.enable: true"
      - "traefik.http.routers.api.entrypoints: web"
      - "traefik.http.routers.api.service: api@internal"

  test-api:
    build: ./node/test-api
    ports:
      - 8100
    labels:
      - "traefik.enable=true"    
      - "traefik.http.routers.test-api.rule=Host(`dev.localhost`) && PathPrefix(`/api/test`)"
      - "traefik.http.routers.test-api.entrypoints: web-secure"

```

On building the compose, I get these errors:

```auto
traefik_1 | time="2019-11-26T00:15:48Z" level=debug msg="FIXME: Got an status-code for which error does not match any expected type!!!: -1" module=api status_code=-1
traefik_1 | time="2019-11-26T00:15:48Z" level=error msg="Failed to retrieve information of the docker client and server host: error during connect: Get https://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: http: server gave HTTP response to HTTPS client" providerName=docker
traefik_1 | time="2019-11-26T00:15:48Z" level=error msg="Provider connection error error during connect: Get https://%2Fvar%2Frun%2Fdocker.sock/v1.24/version: http: server gave HTTP response to HTTPS client, retrying in 1.080381816s" providerName=docker

```

I am looking for help in correcting the config.

Thanks!

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [November 26, 2019, 12:41am UTC](https://community.traefik.io/t/error-in-starting-traefik-with-https/3162/2 "2019-11-26T00:41:52Z")

</div>

Hello,

the error come from Docker it-self [https://github.com/docker/engine/blob/master/errdefs/http\_helpers.go#L66](https://github.com/docker/engine/blob/master/errdefs/http_helpers.go#L66)

```auto
      - --providers.docker.tls.cert=/etc/certs/dev.localhost+4.pem
      - --providers.docker.tls.key=/etc/certs/dev.localhost+4-key.pem  

```

The certificate define by `providers.docker.tls` is for the connection to Docker, not for your services.

If you want to use certificates for your services, you have to define them into the dedicated `tls` section in the dynamic configuration.

[https://docs.traefik.io/v2.0/https/tls/](https://docs.traefik.io/v2.0/https/tls/)

---

<div class="post-metadata">

**Author:** ![aamir\_010a](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@aamir\_010a](https://community.traefik.io/u/aamir_010a)\
**Post date:** [November 26, 2019, 7:42pm UTC](https://community.traefik.io/t/error-in-starting-traefik-with-https/3162/4 "2019-11-26T19:42:21Z")

</div>

Having similar issue. I have gone through the doc but it seems confusing. Any help would much appreciated.

---

<div class="post-metadata">

**Author:** ![sisuser1987](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@sisuser1987](https://community.traefik.io/u/sisuser1987)\
**Post date:** [November 26, 2019, 7:44pm UTC](https://community.traefik.io/t/error-in-starting-traefik-with-https/3162/5 "2019-11-26T19:44:11Z")

</div>

This link has been helpful to me for https. As Idez mentioned, I still have to explore providers.docker.tls

> **[Trouble understanding how traefik picks up a custom SSL certificate for a domain](https://community.traefik.io/t/trouble-understanding-how-traefik-picks-up-a-custom-ssl-certificate-for-a-domain/1867)**
>
> I am having trouble understanding the relation between the router and the provided SSL ceritifcate files. How traefik knows which certificate to choose for a particular domain. I have got following configuration but traefik is providing a default...
