504 Gateway Time-out on nextcloud after container update

To reclaim some disk space, I stopped all my containers, did a

docker system prune -a

followed by

docker-compose up -d

This re-pulled all the images and started the containers. Everything worked fine for a couple of minutes, and then the nextcloud web interface stopped working, giving the 504 error.

I have tried rebooting the server.

Docker-compose: https://pastebin.mozilla.org/RUpCyqfn
Swag log: https://pastebin.mozilla.org/N1Sog1iw
Mariadb log: https://pastebin.mozilla.org/azucF2dE
Nextcloud log: https://pastebin.mozilla.org/jzWAcT8U

And, not sure if this is related, but I notice a lot of mysql stuff happening in htop on the server: https://imgur.com/a/CUE2m90

EDIT: I updated the expired pastebin links
EDIT: I’m running piwigo and some static html sites behind the same swag, and they work fine, so I guess the problem is with my nextcloud.
EDIT: This is probably useful: When I do a docker-compose down, I get these messages:

user@machine:~/docker$ docker-compose down
Stopping nextcloud …
Stopping wireguard …
Stopping swag …
Stopping mariadb … error
Stopping piwigo …
Stopping home-assistant …
ERROR: for home-assistant UnixHTTPConnectionPool(host=‘localhost’, po
rt=None): Read timed out. (read timeout=70)
ERROR: for swag UnixHTTPConnectionPool(host=‘localhost’, port=None):
Read timed out. (read timeout=70)
ERROR: for nextcloud UnixHTTPConnectionPool(host=‘localhost’, port=None): Read timed out. (read timeout=70)
ERROR: for piwigo UnixHTTPConnectionPool(host=‘localhost’, port=None): Read timed out. (read timeout=70)
ERROR: for wireguard UnixHTTPConnectionPool(host=‘localhost’, port=None): Read timed out. (read timeout=70)
ERROR: An HTTP request took too long to complete. Retry with --verbose
to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).