Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php artisan migrate --seed (SQLSTATE[HY000] [2002] Connection refused) #63

Closed
error-try-again opened this issue Aug 9, 2019 · 3 comments

Comments

@error-try-again
Copy link

error-try-again commented Aug 9, 2019

Tooling Versions: FF quantum 68.0.1, npm 6.9.0, composer 1.9.0, Laravel Framework 5.8.13.

When running php artisan migrate --seed I get this error.
If you like I can post the verbose output.


   Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)

  at /root/PROJECTS_RAND/vue_demos/vue_blog_demo/laravue/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [2002] Connection refused")
      /root/PROJECTS_RAND/vue_demos/vue_blog_demo/laravue/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=homestead", "homestead", "secret", [])
      /root/PROJECTS_RAND/vue_demos/vue_blog_demo/laravue/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

This issue prevents me from logging into the dashboard with the developer account and presents as a (500) invalid server error.

I have changed DB_HOST=127.0.0.1 to DB_HOST=localhost in the .env file [1] but this did not resolve my issue.

[1] https://stackoverflow.com/questions/43804784/database-laravel-php-artisan-migrate-connection-refused

@tuandm
Copy link
Owner

tuandm commented Aug 10, 2019

Seems you have problem with MySQL connection. Have you tried to test connecting MySQL with pure PHP/mysql client/mysql command?

@error-try-again
Copy link
Author

error-try-again commented Aug 10, 2019

The problem was that I was using the presets in .env and didn't read the comment properly
# Migration and DB seeder (after changing your DB settings in .env)
Which lead me to assuming that the default settings should work.

I needed to change the line
DB_HOST=127.0.0.1 to DB_HOST=localhost, plus the following lines
DB_DATABASE=whatever db I want
DB_USERNAME=whatever username is set
DB_PASSWORD=password for db

This issue can be closed :)

@vincentmanono
Copy link

just turn on your server, it workde for me. I use ubuntu to code so the cammand i had to run was

/opt/lampp/lampp start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants