Issues with https and trusted domains

Nextcloud version (eg, 20.0.5): 22.0.0
Operating system and version (eg, Ubuntu 20.04): Pop!_OS 21.04
Apache or nginx version (eg, Apache 2.4.25): Don’t Know
PHP version (eg, 7.4): 7.4.3

The issue you are facing:

I am only able to log in to my Nextcloud server using my external IP address via http. Setting up trusted domains in config.php and restarting the server does nothing. Logging in via localhost, local IP or domain name don’t work.

I installed Nextcloud with snap and enabled https.

Is this the first time you’ve seen this error? (Y/N): This is a new server setup.

Steps to replicate it:

  1. install Nextcloud with snap
  2. snap nextcloud.enable-https letsencrypt
  3. add domain and IP addresses to config.php
  4. restart nextcloud
  5. login via web browser desktop client

Log (Desktop Client):

The output of your Apache/nginx/system log in /var/log/____:

I don’t have either of those.

You have a problem with your database connection:

An exception occurred while executing a query: SQLSTATE[08S01]: Communication link failure: 1053 Server shutdown in progress