Application Failed to Respond - no error - PHP Laravel - minimum deploy logs
jandoka3
FREEOP

3 months ago

I am encountering an issue with my Railway deployment. Upon deploying my application, all dependencies are successfully installed, and the application compiles and deploy without any errors. However, when attempting to access the API, I am greeted with the error message "Application failed to respond." Unfortunately, the deployment logs provide minimal insight into the root cause of this issue, as they only display:

"Starting Container"

"INFO Configuration cached successfully. "

My Dockerfile:

FROM php:8.4-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip \
    sqlite3 \
    libsqlite3-dev \
    nodejs \
    npm

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo pdo_sqlite mbstring exif pcntl bcmath gd

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Set working directory
WORKDIR /app

# Copy existing application directory
COPY . .

# Install PHP Dependencies (including dev for Collision)
RUN composer install --optimize-autoloader --no-interaction

# Install NPM dependencies and build assets
RUN npm ci && npm run build

# Create SQLite database file and set permissions
RUN touch /app/database/database.sqlite && \
    chmod -R 775 /app/storage /app/bootstrap/cache && \
    chmod 664 /app/database/database.sqlite

# Expose port (Railway will override with $PORT)
EXPOSE 8080

# Create startup script
RUN echo '#!/bin/bash\n\
set -e\n\
echo "Running migrations..."\n\
php artisan migrate --force\n\
echo "Caching configuration..."\n\
php artisan config:cache\n\
php artisan route:cache\n\
echo "Starting server on port ${PORT:-8080}..."\n\
php artisan serve --host=0.0.0.0 --port=${PORT:-8080}\n\
' > /app/start.sh && chmod +x /app/start.sh

# Start application
CMD ["/app/start.sh"]
Solved$10 Bounty

Pinned Solution

3 months ago

id probably add more logs to see where things are breaking, but a couple of things you can likely do:

  1. remove migrations to see if the app boots up

  2. add a healthcheck to your app

  3. ssh into the service itself (right click -> copy ssh command) and then see if laravel is reading $PORT or curl -i http://127.0.0.1:$PORT to see if it hangs or returns

2 Replies

3 months ago

id probably add more logs to see where things are breaking, but a couple of things you can likely do:

  1. remove migrations to see if the app boots up

  2. add a healthcheck to your app

  3. ssh into the service itself (right click -> copy ssh command) and then see if laravel is reading $PORT or curl -i http://127.0.0.1:$PORT to see if it hangs or returns


yeeet

id probably add more logs to see where things are breaking, but a couple of things you can likely do:remove migrations to see if the app boots upadd a healthcheck to your appssh into the service itself (right click -> copy ssh command) and then see if laravel is reading $PORT or curl -i http://127.0.0.1:$PORT to see if it hangs or returns

jandoka3
FREEOP

3 months ago

Thanks a lot for navigation. I already was capable to manage it with this approaches. I simplified the docker file, then I realized that I have wrong setting in my project. I just deleted the "Custom Start Command" in my settings and everything start to work. :-) Thanks a lot.


Status changed to Solved brody 3 months ago


Loading...