phplaravellaravel-8connection-refused

SQLSTATE[HY000] [2002] Connection refused in Laravel 8


Using Laravel 8

Ubuntu 20.04 with Docker

Connect to Database over clients worked perfect. Docker-Container worked.

If I dont start it with php artisan serve it refused the connection to mysql.

With php artisan serve it connects to mysql-docker-container.

I want deploy it. But if I make it like this doc: https://laravel.com/docs/8.x/deployment it worked fine, but only DB-connection crashes.

I tried: SQLSTATE[HY000] [2002] Connection refused within Laravel homestead

But if I change the Host it answer with this mistake: PDOException: SQLSTATE[HY000] [2002] No such file or directory

need help.


Solution

  • dont forget... WSL :)

    use mysql not localhost.