Laravel Error 500 Whoops, looks like something went wrong – Exception

When you get an error 500 screen with a red bar at the top stating Whoops, looks like something went wrong. running your Laravel app you might spend a lot of time debugging your Nginx configuration like I did before. You will be looking at the wrong place. Here is what is up and how you can solve this.

Laravel Error

This error you are getting in the top bar besides the general error 500 warning in the access logs probably at /var/log/nginx/error.log  stating Whoops, looks like something went wrong followed by the ghost icon and word Exception is a Laravel error. The red bar and text is generated by Laravel , not Nginx!. So you should check the Laravel log to see what is up. And perhaps you have not turned on Laravel logging properly so you will then need to add:

APP_ENV=local

to the .env file. In my case the issue was that is was all empty as I was working on setting up a new deployment mechanism.

NB If if it was not for you and you did have this line then you simply need to check the log.

Laravel Logging

With error logging now finally working (if you did had an empty .env as me before) you will start logging in Laravel. You will be able to see this kind of error in storage/logs/laravel.log :

production.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in /var/www/domain.com/releases/1/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:43

followed by the full stack trace. This as you are also missing your Laravel key in the .env as well.

Generating Laravel Key

To fix this missing key issue do a:

php artisan key:generate

Then copy the output in the brackets, and put it in your .env file as:

APP_KEY=base64:keygoeshere

Clearing Laravel Cache

Then you need to clear the cache to load the new key / .env changes. To do this do a:

 php artisan config:clear

followed by a:

php artisan config:cache

Now you should be able to see the Laravel welcome page or whatever page you have set up to load as the main page for the domain.

Tagged in : Tagged in : ,
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.