Repository navigation
Laravel autorun failing on database connection. #672
Copy link
Copy link
Labels
🧐 Bug: Needs ConfirmationSomething isn't working, but needs to be confirmed by a team member.Something isn't working, but needs to be confirmed by a team member.
Description
Steps To Reproduce
I am running the php:8.5-fpm-nginx image with the following Dockerfile:
Dockerfile
FROM serversideup/php:8.5-fpm-nginx
ARG RELEASE=unknown
ENV NGINX_WEBROOT=/var/www/html/public
ENV PHP_MEMORY_LIMIT=512M
ENV PHP_OPCACHE_ENABLE=1
ENV AUTORUN_ENABLED=true
ENV AUTORUN_LARAVEL_STORAGE_LINK=true
ENV AUTORUN_LARAVEL_MIGRATION=true
ENV RELEASE=$RELEASE
# Install mysql client (needed by Laravel's schema loading) and PHP extensions
USER root
RUN apt-get update && apt-get install -y --no-install-recommends default-mysql-client && rm -rf /var/lib/apt/lists/* \
&& echo "[client]\nssl = 0" > /etc/my.cnf
RUN install-php-extensions gd redis igbinary zip
# Custom startup script (runs after AUTORUN migrations)
COPY --chmod=755 .docker/entrypoint.sh /etc/entrypoint.d/99-app-init.sh
RUN docker-php-serversideup-s6-init
# Register queue worker as an S6 longrun service
COPY --chmod=755 .docker/s6/queue-worker/ /etc/s6-overlay/s6-rc.d/queue-worker/
RUN touch /etc/s6-overlay/s6-rc.d/user/contents.d/queue-worker
USER www-data
COPY --chown=www-data:www-data . /var/www/html
RUN composer install --no-interaction --no-progress --optimize-autoloaderUpon boot I get the following error:
app-1 | ⚡️ Attempting connection to default database...
app-1 | 👉 DEBUG (laravel-automations): Waiting for connection to default database (timeout: 30s)
app-1 | [2026-04-15 07:01:15] production.ERROR: Class "DB" not found {"exception":"[object] (Error(code: 0): Class \"DB\" not found at /etc/entrypoint.d/lib/laravel/test-db-connection.php:84)
app-1 | [stacktrace]
app-1 | #0 {main}
app-1 | "}
app-1 |
app-1 | Error
app-1 |
app-1 | Class "DB" not found
app-1 |
app-1 | at /etc/entrypoint.d/lib/laravel/test-db-connection.php:84
app-1 | 80▕
app-1 | 81▕ // Test database connection
app-1 | 82▕ try {
app-1 | 83▕ // Use specific database connection if provided
app-1 | ➜ 84▕ $connection = $databaseConnection ? DB::connection($databaseConnection) : DB::connection();
app-1 | 85▕ $driver = $connection->getDriverName();
app-1 | 86▕
app-1 | 87▕ // SQLite special handling
app-1 | 88▕ if ($driver === 'sqlite') {
app-1 |
app-1 | Waiting on default database connection, retrying... 30 seconds left
app-1 | 👉 DEBUG (laravel-automations): Connection attempt 1/30 failed for default database (status: 1)
I believe this happens because the DB facade is used without being imported.
Outcome
What did you expect?
The container to boot
What happened instead?
The container keeps crashlooping
Affected Docker Images
"org.opencontainers.image.title": "serversideup/php (fpm-nginx)",
"org.opencontainers.image.version": "v4.3.5-24389473373",
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🧐 Bug: Needs ConfirmationSomething isn't working, but needs to be confirmed by a team member.Something isn't working, but needs to be confirmed by a team member.
Activity
jaydrogers commentedon Apr 16, 2026
Let me know if this is happening for you on our test image:
This will be available in our 4.4 release:
jaydrogers commentedon Sep 10, 2026
Closing because it went stale