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

**Code:** `Sail: getaddrinfo failed for host mysql` · **Category:** Laravel · **Seen on:** Laravel, PHP, Docker

Commands run outside the Sail container (on the host) try to resolve the Docker service name `mysql`, which only exists inside the Docker network.

## Meaning

Run artisan inside the container: `./vendor/bin/sail artisan migrate`. If you want to run from the host, set `DB_HOST=127.0.0.1` and use the forwarded port (`FORWARD_DB_PORT`). Also make sure containers are up (`sail up -d`) and MySQL finished initialising.

## Common causes

- Running `php artisan migrate` on the host with `DB_HOST=mysql`
- Containers not started
- MySQL container still booting
- Port conflicts (3306 already used)
- Wrong network

## Quick fix

1. Use `./vendor/bin/sail artisan ...`
2. Or set `DB_HOST=127.0.0.1` for host commands
3. `./vendor/bin/sail up -d` and wait for health

## Detailed fix by platform

### Docker

1. `./vendor/bin/sail up -d && ./vendor/bin/sail artisan migrate`

## How to diagnose

1. **Where** — Host or container?
2. **DB_HOST** — Service name vs localhost?
3. **Containers** — Running?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/laravel/sail-mysql-host-not-resolving)
