laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.65k stars 470 forks source link

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Temporary failure in name resolution #687

Closed cage81 closed 5 months ago

cage81 commented 5 months ago

Sail Version

1.29

Laravel Version

11.1.1

PHP Version

8.3.4

Operating System

Windows (WSL)

OS Version

Ubuntu 22.04

Description

On a fresh Laravel 11 installation, the main page is not reachable showing the following error:

image

It coulb be a bug, the reasolution I found un an old post is to change the .env file adding this line:

DB_HOST=host.docker.internal

I changed the following things in the docker-compose.yml before the sail build command:

service name form laravel.locale to project-name.locale laravel service port from 80 to 8280 mysql service name from mysql to *projectname-mysql**

Steps To Reproduce

composer create-project laravel/laravel:^11.0 project-name
composer require laravel/sail --dev
php artisan sail:install
sail up -d
driesvints commented 5 months ago

Using your exact steps, together with sail artisan migrate, I get a running Laravel app. Most likely this was a temp hiccup.