I don't think there's a way for php running in homestead to connect to a database running on the host. At the very least you'll have to replace the database ip with the host ip in homestead/vagrant and check that the mariadb installation in xamp are't blocking external connections by default.
[SOLVED] Homestead database configuration
Hi, I just configured homestead and everything is perfect, except for the configuration to the database ... I can not connect my application with the mariadb database of xampp ... can anyone help me? I already read the laravel documentation and try to configure it but I can not do it ... When I try to access the database through my application I get the following error:
Illuminate \ Database \ QueryException (2002)
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from users where email = [email protected] limit 1)
Previous exceptions SQLSTATE[HY000] [2002] Connection refused (2002)
This is my .env configuration
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:bv8q5PTnQ+jm/UQ3Eu/77XdsQGCxTOdJSMOxCvON+hw=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tutorial
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
TWITTER_KEY=public-key
TWITTER_SECRET=secret-key
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Thank you.
Please or to participate in this conversation.