-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
SQLSTATE[HY000] [2002] Connection refused #1323
Comments
Yep, i tried. And is the port 3307.
Without using laravel, and using just using pdo, the connection works fine.
But with laravel / eloquent, nothing works.....
Im lost....
…________________________________
De: Lucas C. S. Silva <notifications@github.com>
Enviado: quarta-feira, 27 de dezembro de 2017 22:50:47
Para: laradock/laradock
Cc: Rodrigo Batista; Author
Assunto: Re: [laradock/laradock] SQLSTATE[HY000] [2002] Connection refused (#1323)
Have you tried to change the MYSQL_HOST to mysql or mariadb, depending on which database container you are using? Is the port 3307 correct as well?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1323 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AWawCgp9rBB4yvGK6Yg4BqC_r8o0-spzks5tEuXngaJpZM4RN6V_>.
|
Use as @InTheDeepEnd said below, your .env should look like this:
If you want to run php artisan commands outside of the workspace container, you can set |
@omag0 when you want to use cli commands, like
|
@harrysbaraini answer is correct. In simpler terms, your laravel .env should look like this :
|
I'm facing this problem as well, but i've already config. my
|
I am getting the exact same error as @rafa-acioly with the same .env file. This has been running fine for a few months. Made no changes to the Laradock files Getting this error from a clean install and running from a Laradock fork which has not failed me until now. |
Just had the same problem. Turned out that this was due to a misconfiguration. I think I'll post a complete example, might help others to understand the issue. Given you have the following section in your laradock .env
Then you need the following laravel .env
Then you can
Wondering why Actually, the port you specified in laradock's .env is the port mapped to the host. It should not matter for container communication. Guessing what to do if you wanted to change the port for containersI guess, if you wanted to change the mysql port for container communication, you would need to change mysql/my.cnf
And you might need to change the mysql/Dockerfile to
|
Use container name of mysql in DB_HOST. Like this DB_HOST=laravellocal_mysql_1 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi again 👋 we would like to inform you that this issue has been automatically |
I have to say thanks to. you. Love it |
Anyone still facing this issue - If you ran |
Hello guys. Have a problem, and need help.
I clone laradock in /var/www/docker/laradock
than i make docker-compose up -d apache2 mysql
and in /var/www/docker i run laravel new project.
my laradock .env
MYSQL_VERSION=8.0
MYSQL_DATABASE=AriesDB
MYSQL_USER=default
MYSQL_PASSWORD=secret
MYSQL_PORT=3307
MYSQL_ROOT_PASSWORD=root
MYSQL_ENTRYPOINT_INITDB=./mysql/docker-entrypoint-initdb.d
my laravel .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
DB_DATABASE=AriesDB
DB_USERNAME=root
DB_PASSWORD=root
when i do "php artisan migrate" and "php artisan db:seed" everything works ok
buy when i run my browser and put my login and password, show this messenger SQLSTATE[HY000] [2002] Connection refused (SQL: select * from
users
whereemail
= rodrigo@com.br limit 1).if i do docker-compose exec workspace bash, and try "php artisan migrate" show this messenger: SQLSTATE[HY000] [2002] Connection refused
I tryied change DB_HOST=127.0.0.1 to DB_HOST=mysql but nothing changed.
Can somebody help me?
The text was updated successfully, but these errors were encountered: