500 Internal Server Error

Website URL

500 Internal Server Error Something on the website crashed!

Other Information

I developed a school website using Laravel and I would like to test it before actually using a paid hosting for full implementation. Unfortunately, I am getting the error stated above everytime I try to access the website.

Here’s what I have done so far:

  • Created a Database and imported tables without error
  • Configured database as per my MySQL Connection Details (yes, the app does uses MySQL)
  • Moved .htaccess in /htdocs (originally placed inside public folder)
  • Modified .env file to reflect the server’s configurations

.env config

 APP_NAME=DCCP-ABRA
 APP_ENV=production
 APP_KEY=base64:IAMNOTGONNAUSETHEACTUALKEY
 APP_DEBUG=true
 APP_URL=http://dccp-abra.ct.ws

 APP_LOCALE=en
 APP_FALLBACK_LOCALE=en
 APP_FAKER_LOCALE=en_US

 APP_MAINTENANCE_DRIVER=file
 # APP_MAINTENANCE_STORE=database

 # PHP_CLI_SERVER_WORKERS=4

 BCRYPT_ROUNDS=12

 LOG_CHANNEL=stack
 LOG_STACK=single
 LOG_DEPRECATIONS_CHANNEL=null
 LOG_LEVEL=debug

 DB_CONNECTION=mysql
 DB_HOST=sql311.infinityfree.com
 DB_PORT=3306
 DB_DATABASE=IAMNOTGONNASHOWITHERE
 DB_USERNAME=IAMNOTGONNASHOWITHERE
 DB_PASSWORD=IAMNOTGONNASHOWITHERE

 SESSION_DRIVER=database
 SESSION_LIFETIME=120
 SESSION_ENCRYPT=false
 SESSION_PATH=/
 SESSION_DOMAIN=null

 BROADCAST_CONNECTION=log
 FILESYSTEM_DISK=local
 QUEUE_CONNECTION=database

 CACHE_STORE=database
 # CACHE_PREFIX=

 MEMCACHED_HOST=127.0.0.1

 REDIS_CLIENT=phpredis
 REDIS_HOST=127.0.0.1
 REDIS_PASSWORD=null
 REDIS_PORT=6379

 MAIL_MAILER=log
 MAIL_SCHEME=null
 MAIL_HOST=127.0.0.1
 MAIL_PORT=2525
 MAIL_USERNAME=null
 MAIL_PASSWORD=null
 MAIL_FROM_ADDRESS="[email protected]"
 MAIL_FROM_NAME="${APP_NAME}"

 AWS_ACCESS_KEY_ID=
 AWS_SECRET_ACCESS_KEY=
 AWS_DEFAULT_REGION=us-east-1
 AWS_BUCKET=
 AWS_USE_PATH_STYLE_ENDPOINT=false

 VITE_APP_NAME="${APP_NAME}"

.htaccess config

Options -MultiViews -Indexes
RewriteEngine On
RewriteRule (.*) /public/$1 [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Handle X-XSRF-Token Header
RewriteCond %{HTTP:x-xsrf-token} .
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]

Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /public/$1 [L]

index.php

<?php

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
} 

// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';

// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';

$app->handleRequest(Request::capture());

What am I doing wrong or what did I miss? Thank you in advance.

Are you actually trying to use Redis and Memcached or not because those are not supported

Besides InfinityFree is not a trial. If you want to evaluate iFastNet you need to get iFastNet hosting not InfinityFree because those are two very very different services

Not yet.. I’m just trying to test the project in a live environment. Should I comment them out?

Anyways, I just modified the .htaccess file and replace some of the codes with:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L]

Now I am receiving the 500 Server Error but this time, it has the layouting of my project unlike earlier (500 Server Error page of infinity).

This means your PHP code crashed. We don’t know what your code is so we cannot just help you like that, but you could start with enabling debug in Laravel so you get the actual error message instead of a generic error.

I have enabled DEBUG (set them all to true) in Infinity’s PHP settings, in the .env file and in config/app.php

I am still not seeing the PHP error messages, just the plain

I forgot to ask. My account is newly created so, is the DNS caching if 72 hours can cause the problem?

No, DNS caching does not give 500 errors.

Seeing the Laravel error page is strong proof that nothing is wrong with DNS. As of why it is still not showing any debug info, I don’t know.

Enabling APP_DEBUG should give you a real error message, so it’s strange that it doesn’t work.

I checked your website and I think I found the reason. The bootstrap/cache/ folder contains a cached PHP config file. Since that file is present, Laravel doesn’t check the config files or .env file, and just uses the cached data. And in that cached config, the debug option is disabled.

I suggest you start by deleting all PHP files in the bootstrap/cache folder and then refreshing the page to see if you can get a real error message.

Did this and now the homepage is working. However, all the views (after clicking the navbar) are giving

Should I recreate the deleted files again?

It’s start by leading your browser cache to make sure it’s not decided to cache a broken page… Happens too often

That 500 error page usually indicates a problem with your .htaccess file.

Looking more closely at your .htaccess setup, I think I can see why that is.

My recommendation for setting up Laravel is to put a small .htaccess file in the htdocs directory and leave the official htdocs in-tact.

You appear to have moved the original .htaccess and have attempted to modify it for the different subdirectory. It’s possible to make a Laravel site work that way too, but it’s a lot more complicated and more likely to break with upgrades. Your current rules are not cutting it, at least.

Originally, the .htaccess was located at /public. I moved it outside (htdocs). Let me try to put it back to the og location and then undo the rules I added in.

Alright, thanks.. I deleted all the contents of my htdocs and reuploaded the files again, basically went back to zero.

Followed all the steps in the link you provided. Now its all working.
Thank you very much.