During a new App setup, app migration or update, Laravel might show the error : “Whoops, looks like something went wrong.”
Errors can be frustrating, but what makes it even more frustrating is when it is cryptic like this:
Here at Bobcares, Our Support Engineers maintain hundreds of Laravel sites of web hosts, web designers, and more.
In these sites, we’ve seen a wide range of reasons for this error that ranges from missing PHP extensions to outdated composers.
Let’s take a quick look at the top 7 causes we’ve seen for this error, and how we fix them.
1. Missing PHP extensions
By default, PHP packages come with a minimal set of extensions.
During new App setup or migrations, we’ve seen cases where the app user forgot to setup all the required extensions such as OpenSSL, Tokenizer, etc.
This will cause the app code to fail, and Laravel to show “Whoops, looks like something went wrong.”.
Solution : In such cases, we go through the app requirement specs and make sure (1) the extensions are installed and (2) the paths to the extensions are set right in the PHP config used by the app.
2. Wrong file or folder permissions
Laravel apps write to cache and log folders during app execution.
For this to happen, these folders should have “write” permission set for the PHP user.
Depending on how PHP is configured in the server, it should be either “755” or “777” for these folders.
Solution : In servers that run PHP as the site user (eg. SuPHP), we set the permissions 755 for “storage” and “bootstrap/cache” directories. In others (eg. mod_php), we set it as 777.
Note : There could be additional configuration settings for PHP that can invalidate the above rule. So, if you are not sure what the permissions should be, contact our Laravel administrator. We are online 24/7.
3. Application key not generated or invalid
Laravel uses a 32 character long “application key” to create user sessions and encrypt data.
This is usually automatically set when Laravel is installed using the “composer” tool.
However, during migrations or during non-standard setup, we’ve seen this key to be not set or copied incorrectly.
This causes the sessions to fail, and app causing the error “Whoops, looks like something went wrong.”
Solution : We create a new app key with the command php artisan key:generate
and update the APP_KEY
entry in the environment file (.env
).
4. Environment (“.env”) file not set
Laravel stores the application settings in a file called “.env” in the app’s home directory.
Since this is a hidden file, it may get omitted during app migrations.
It is also possible that novice users forget to create this file during new app setup.
Solution : In the case of migrations, we copy the .env
file from the source server, and in the case of new setup, we use the default .env.example
file to create a new .env
file.
5. Outdated composer
Laravel uses a package called “composer” to install, maintain and update apps.
Some app updates may require the latest version of “composer” to be available in the server. If not, the app update might fail showing the error, “Whoops, looks like something went wrong.”.
Solution : In such cases, we update the composer with the commands composer self-update
or composer global update
or composer update
, depending on the kind of issue we’re facing.
6. Stale Laravel config cache
Often it takes many app reloads to iron out the small issues during new setup, updates or migrations.
The config files may change many times during these times. But Laravel might cache the old config settings, often causing the app to fail with the “something went wrong” error.
Solution : To fix this, we delete the config cache with the command php artisan config:cache
. This will force Laravel to build a new combined config file using the latest versions of files stored under the config
directory.
7. Code sync errors
App updates can sometimes get messy with broken paths and incorrect permissions preventing proper download of app files.
We’ve also see users making custom changes that cause syntax errors.
Any of these can cause the application to fail with the “something went wrong” error.
Solution : In such cases, the fastest way to resolution is to restore the old app version from backup. If that is not an option, we trace the files that were changed the last, and replace it with the unmodified versions from the app repository. We also check if this is a reported bug by the developer.
What next? – Enable debugging to dig deeper
When faced with the “something went wrong” error, our first step is to enable detailed error log by setting “APP_DEBUG” as “true” in app/config/app.php.
This gives us the exact reason for the error, and helps us resolve the issue in a few minutes.
However, these error messages can be pretty confusing for someone not familiar with Laravel development.
If you followed the steps above, and none of it seemed to work, you may need to dig deeper with the debugging. In case you need assistance, click here to request assistance from our Laravel experts.
Conclusion
Laravel shows the error “Whoops, looks like something went wrong.” for any error on the site. Today, we’ve covered the top 7 reasons for this error, and what we do to fix them.
It works for me, thank you! 🙂
Thanks it covered almost the problems during initiation;
Sua dica me ajudou muito. No meu caso, como havia migrado os arquivos, o arquivo “.evn” não migrou junto. Valeu, muito obrigado mesmo!!!
Obrigado Donizete pelas palavras amáveis! 🙂
My Issue, Hard Drive Was Full
my problem is not fixed yet
Hello Shinu,
We can take a closer look at your Laravel settings. If you still have the error and need help, we’ll be happy to talk to you on chat (click on the icon at right-bottom).