[2002] Connection refused means your app reached a network address but nothing accepted the connection there. The database is down, on a different host, or — most often in Docker — you used the wrong hostname.
The Error
SQLSTATE[HY000] [2002] Connection refused
Cause 1: MySQL Isn't Running
# Is it up?
sudo service mysql status
# Start it
sudo service mysql startCause 2: Wrong Host in Docker
Inside a Docker container, 127.0.0.1 points at the container itself, not your database container. Use the service name from docker-compose.yml as the host:
# .env — use the compose service name, not 127.0.0.1
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=app
DB_USERNAME=root
DB_PASSWORD=secretCause 3: Wrong Port
Local MySQL defaults to 3306, but MAMP uses 8889 and some setups remap it. Confirm what is actually listening:
lsof -i -P | grep mysqlAfter Editing .env
Always run php artisan config:clear. Laravel caches config, so .env changes are ignored until you clear it — a classic 'I fixed it but it still fails' trap.
