access denied for user homestead localhost

Not quite sure why this is happening:

My database.php file:

Any help is appreciated!!

Please sign in or create an account to participate in this conversation.

The most concise screencasts for the working developer, updated daily.

There’s no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!

Want us to email you occasionally with Laracasts news?

Nine out of ten doctors recommend Laracasts over competing brands. Come inside, see for yourself, and massively level up your development skills in the process.


© Laracasts 2019. All rights reserved.
Yes, all of them. That means you, Todd.

Designed with by Tuds.
Proudly hosted with Laravel Forge and DigitalOcean.

I’m on a Mac OS Yosemite using Laravel 5.0.

While in my local environment, I run php artisan migrate I keep getting :

Access denied for user ‘homestead’@’localhost’ (using password: YES)


Here is my .env


How do I avoid this kind of error ?

I’ve tried :

in app/database.php

Replace localhost with

‘host’=> env(‘DB_HOST’, ‘localhost’) —> ‘host’ => env(‘DB_HOST’, ‘’)

Also, in .env

Try specify environment

php artisan migrate —env=local

Check to see if the MySQL is running by run

mysqladmin -u homestead -p status Enter password: secret

Uptime: 21281 Threads: 3 Questions: 274 Slow queries: 0 Opens: 327 Flush tables: 1 Open tables: 80 Queries per second avg: 0.012

Which mean it’s running.

Check MySQL UNIX Socket (This step work for me)

28 Answers 28

The reason of Access denied for user ‘homestead’@’localhost’ laravel 5 error is caching-issue of the .env.php file cause Laravel 5 is using environment based configuration in your .env file.

1. Go to your application root directory and open .env file (In ubuntu may be it’s hidden so press ctrl + h to show hidden files & if you are in terminal then type : ls -a to show hidden files) in your editor and change database configuration setting. then save your .env file

2. then restart your apache server/web server. and refresh your page and you have done

3. If still issue try to run below command to clear the old configuration cache file.

Fix : Access denied for user ‘homestead’@’localhost’

Fix for : Access denied for user ‘homestead’@’localhost’

You are here because you are working on a Laravel Project and on Opening of the project web page you see this error.

Access denied for user ‘homestead’@’localhost’ Error

The solution to this error is pretty simple. You have a .env file in your project. The .env file contains different property variables which applies to your project environment.

This include database connection properties, Application key value , SMTP Details etc.

In the default .env file the database settings are set to something like this

You need to change the DB_DATABASE , DB_USERNAME , DB_PASSWORD as per your local mysql settings in the .env file of your project

Once you correct these property variables in .env file, you should be able to access your application page.

If you have already changed the database property variables in .env file and you are still not able to access your project.

Follow these two additional steps.

Open your terminal , Go to the project root directory and execute this artisan command.

Restart your Apache server and refresh the page. You no longer see the Error.

Оцените статью
Добавить комментарий