Laravel login throws a RuntimeException about the Bcrypt algorithm
This password does not use the Bcrypt algorithm.Short answer
Hash::check first confirms that the stored hash was made with the hashing algorithm your app is set to use. If it was not, Laravel throws a RuntimeException instead of returning false. Either the stored value is not a Laravel hash at all, or HASH_DRIVER names a different algorithm than the one that made it. Match the driver to the data, or migrate with HASH_VERIFY temporarily off.
Fix it fast
1Find out which cause you have
Print the stored value for one failing user and compare it with the driver the app uses. The two have to be the same algorithm.
// in php artisan tinker echo App\Models\User::first()->password; echo config('hashing.driver');2Match what you see, then jump to its fix
- 1
The password column holds plain text or a hash from some other systemThe stored password was never hashed by LaravelFix - 2
HASH_DRIVER (or config/hashing.php) names an algorithm other than the one that made the stored hashes, for example after switching between bcrypt, argon and argon2idThe hashes were made by another Laravel driver than the one configuredFix
- 1
What does the error look like?
This password does not use the Bcrypt algorithm.RuntimeException thrown from Hash::check during login
Cause 1 of 2
The stored password was never hashed by Laravel
1Check
Rows written by a raw INSERT, a careless seeder or an import from another application keep the format they arrived in.
// in php artisan tinker
echo App\Models\User::first()->password;2Fix
Write the password again through Hash::make. If you do not know the plain-text password, send the user through a password reset instead.
use Illuminate\Support\Facades\Hash;
$user->password = Hash::make($plainPassword);
$user->save();3Verify
Log in as that user.
// in php artisan tinker
Hash::check($plainPassword, $user->fresh()->password);Confirmed by laravel.com
Cause 2 of 2
The hashes were made by another Laravel driver than the one configured
1Check
By default Laravel uses the bcrypt driver. The driver comes from the HASH_DRIVER environment variable or the hashing config file, and a stale cached config can hide a change.
grep -n "HASH_DRIVER" .env
php artisan config:clear2Fix
Set HASH_DRIVER to the algorithm your stored hashes use. If you are moving users from one algorithm to another and both kinds exist for a while, set HASH_VERIFY=false so Hash::check stops testing the algorithm. Turn it back on after every hash has been replaced.
# .env
HASH_DRIVER=bcrypt
# only while two algorithms coexist
HASH_VERIFY=false3Verify
Clear the config cache and log in with a known account.
php artisan config:clearConfirmed by laravel.com
How do I stop it coming back?
- Create and update passwords only through Hash::make, never with a raw value in an INSERT or seeder.
- When importing users from another system, plan the hash migration first and remove HASH_VERIFY=false once every hash is converted.
- Set HASH_DRIVER in .env.example so every environment uses the same algorithm.
- Use Hash::needsRehash after a successful login so a changed work factor rolls out by itself.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix