Persistent HTTP 500 (Internal Server Error) on Nextcloud First Run Setup (Homelab)

The Basics

Field Value Notes
Nextcloud Server version Latest (32.0.0.13) Based on the LinuxServer image tag latest and logs.
Operating system and version Debian 12 (Host), Kernel 6.12.38
Web server and version Nginx/PHP-FPM (Internal to LSIO)
Reverse proxy and version Traefik (latest) Running in a separate Docker stack on the host.
PHP version PHP 8.x Based on the LSIO base image.
Is this the first time you’ve seen this error? Yes
When did this problem seem to first start? Immediately upon first deploy/access.
Installation method Docker Compose (LinuxServer.io Image)
Are you using Cloudflare, mod_security, or similar? No

Summary of the issue you are facing:

I am attempting the first-run installation of Nextcloud via the browser (accessing via Traefik at https://nextcloud.mydomain.com/), but it consistently returns an HTTP 500 Internal Server Error. The issue is a silent crash—no application errors appear in Nginx/Apache logs, and the PHP-FPM log shows only normal startup/shutdown events.

The Nextcloud container initializes successfully, and the database connects correctly.

This is my first time setting up Nextcloud, so I may be missing something basic.

Steps to replicate it (hint: details matter!):

  1. Stop and delete all persistent data (config, data, db).

  2. Deploy the attached docker-compose.yml.

  3. Ensure the db volume is manually fixed after deployment: sudo chown -R 1000:1000 /home/user/docker/nextcloud/db.

  4. Restart the stack.

  5. Navigate to https://nextcloud.mydomain.com/ (resolved locally by Pi-Hole).

  6. The browser immediately displays an HTTP 500 error instead of the web installer.

Extensive Troubleshooting Completed:

We have systematically eliminated all external and internal configuration causes:

  1. Networking/Proxy: Traefik is correctly routing, using HTTPS (presumably with a self-signed or internal certificate for now), and the necessary overwriteprotocol: https and trusted_domains settings are configured via Traefik labels.

  2. Database Connection: DB passwords were fixed (no spaces/quotes). Container logs confirm MariaDB is running and accessible to the Nextcloud container.

  3. Permissions: All host bind mounts (config, data, db, db_config) are confirmed to be owned by PUID/PGID 1000:1000.

  4. PHP Resource Limits: Increased both the memory and execution time limits to aggressive values: PHP_MEMORY_LIMIT=1024M and PHP_MAX_EXECUTION_TIME=3600 to bypass known first-run issues.

Log entries

Nextcloud PHP-FPM Log (/config/log/php/error.log)

The log shows normal PHP-FPM lifecycle events (startup/shutdown) but no fatal errors corresponding to the HTTP 500 request time.

Code snippet

[04-Oct-2025 16:44:53] NOTICE: Terminating ...
[04-Oct-2025 16:44:53] NOTICE: exiting, bye-bye!
[04-Oct-2025 16:44:59] NOTICE: fpm is running, pid 318
[04-Oct-2025 16:44:59] NOTICE: ready to handle connections
# (HTTP 500 error occurs here, but no PHP log entry is generated)

Nextcloud Application Log (/data/nextcloud.log)

The only entries are the expected, benign “Not installed” errors from the background cron job:

JSON

{"reqId":"zv0R98E86I8kZ08ApRfG","level":3,"time":"2025-10-04T22:45:00+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Not installed","userAgent":"--","version":"","exception":{"Exception":"Exception","Message":"Not installed","Code":0,"Trace":[{"file":"/app/www/public/lib/base.php","line":703,"function":"checkInstalled","class":"OC","type":"::"},{"file":"/app/www/public/lib/base.php","line":1192,"function":"init","class":"OC","type":"::"},{"file":"/app/www/public/cron.php","line":29,"args":["/app/www/public/lib/base.php"],"function":"require_once"}],"File":"/app/www/public/lib/base.php","Line":226,"message":"Not installed","exception":{},"CustomMessage":"Not installed"}}

Configuration

Docker Compose File (from Portainer)

version: '3.8'

services:
  db:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: nextcloud-db
    restart: unless-stopped
    volumes:
      - /home/user/docker/nextcloud/db:/var/lib/mysql
      - /home/user/docker/nextcloud/db_config:/config
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Denver
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=${NEXTCLOUD_DB_USER}
      - MYSQL_PASSWORD=${NEXTCLOUD_DB_PASSWORD}
    networks:
      - nextcloud_backend

  nextcloud:
    image: lscr.io/linuxserver/nextcloud:latest 
    container_name: nextcloud
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Denver
      - NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.mydomain.com
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=${NEXTCLOUD_DB_USER}
      - MYSQL_PASSWORD=${NEXTCLOUD_DB_PASSWORD}
      - MYSQL_HOST=nextcloud-db
      - NEXTCLOUD_DATA_DIR=/data/nextcloud-data
      - PHP_MEMORY_LIMIT=1024M        # Increased for stability
      - PHP_MAX_EXECUTION_TIME=3600   # Increased to bypass timeouts
    volumes:
      - /home/user/docker/nextcloud/config:/config 
      - /home/user/docker/nextcloud/data:/data 
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    networks:
      - proxy
      - nextcloud_backend
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud.rule=Host(`nextcloud.mydomain.com`)"
      - "traefik.http.routers.nextcloud.entryPoints=websecure"
      - "traefik.http.routers.nextcloud.tls=true"
      - "traefik.http.routers.nextcloud.tls.certResolver=cfresolver"
      - "traefik.http.services.nextcloud.loadbalancer.server.port=443"
      - "traefik.http.services.nextcloud.loadbalancer.server.scheme=https"
      - "traefik.http.services.nextcloud.loadbalancer.passHostHeader=true"
      - "traefik.http.middlewares.nextcloud-headers.headers.sslredirect=true"
      - "traefik.http.routers.nextcloud.middlewares=nextcloud-headers@docker"

networks:
  proxy:
    external: true
  nextcloud_backend:
    internal: true

Conclusion / Call for Help

The containers initialize successfully and talk to each other, but the web access crashes on the first request. I’m at a loss as to what is causing the failure on the LinuxServer image. Any insight would be greatly appreciated and I’m happy to provide additional information as requested.

Thanks!

You are sure it is not one of the proxies?