portainer: Question: How to debug a "Unable to retrieve templates" error

Question:

I’m getting a “Unable to retrieve templates” error on portainer while trying to access the templates section after configuring it to use a custom template.

I already tried to see if it was a network problem by creating a new container on the same network as the portainer one and I was able to successfully wget the template file link.

I also saw no log entries about this issue on the container logs.

How can I check the real reason why portainer was unable to retrieve the templates?

Here’s a screenshot of the referenced error: screen shot 2018-07-05 at 16 00 52

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Ok I’ve solved it. For future reference, my portainer app template file had no opening and closing brackets.

Can’t be:

{
    "type": "stack",
    .
    .
    .
}

Has to be:

[
  {
    "type": "stack",
    .
    .
    .
  }
]

@Justinio99 Verify that the Synology firewall settings under Security\Firewall in DSM are not blocking the port used by Portainer to fetch the templates. You will get that error if that is the case.

THis worked for me. For anyone who is interested:

image whitelist(Allow) this IP range with subnet 255.255.0.0 in Security/Firewall

Have the same problem. Lets see if I can describe all my configuration.

I have created the portainer docker with the command:

sudo docker create --name=pidocker \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /media/Multimedia/home/helio/docker_data/portainer/data/:/data \
-v /media/Multimedia/home/helio/docker_data/portainer/shared/:/shared \
-e PGID=0 -e PUID=0 \
-e TZ=Europe/London \
-p 8001:8000 \
-p 9000:9000 \
portainer/portainer-ce

The app templates is the default in the installation: image

When I go to app templates I get the error: image

Looking the chrome debug: image

Looking the portainer logs:

2020/12/05 17:19:18 http error: Unable to retrieve templates via the network (err=Get https://raw.githubusercontent.com/portainer/templates/master/templates-2.0.json: Bad Request) (code=500)

Trying to reach the url from the docker host:

$ sudo docker ps | grep portai
104df52cb3fe        portainer/portainer-ce   "/portainer"             2 hours ago         Up 2 hours          0.0.0.0:9000->9000/tcp, 0.0.0.0:8001->8000/tcp   pidocker
$
$ wget https://raw.githubusercontent.com/portainer/templates/master/templates-2.0.json
--2020-12-05 17:21:53--  https://raw.githubusercontent.com/portainer/templates/master/templates-2.0.json
A resolver raw.githubusercontent.com (raw.githubusercontent.com)...151.101.0.133, 151.101.64.133, 151.101.128.133, ...
A conectar raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... conectado.
Pedido HTTP enviado, a aguardar resposta...200 OK
Tamanho: 25759 (25K) [text/plain]
Saving to: ‘templates-2.0.json’

templates-2.0.json            100%[=================================================>]  25,16K  --.-KB/s    in 0,005s

2020-12-05 17:21:53 (4,67 MB/s) - ‘templates-2.0.json’ saved [25759/25759]

My nginx configuration to reach portainer from browser:

    location / {

        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Connection "";
        proxy_pass http://localhost:9000; # Portainer

        #access_log off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /api/websocket/ {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_pass http://localhost:9000/api/websocket/;
    }

Can someone point me what do I need to do to get App Templates running?