Laravel Homestead can't connect to MySQL database.

Laravel Homestead: cannot connect to MySQL database

If you would like to install / upgrade Laravel Homestead, you might encounter that you can not connect to the database anymore via a tool like Sequel Pro / TablePlus.

This can have various causes.

Cause 1. Sequel Pro does not support MySQL 8

Because Sequel Pro does not support MySQL 8, it can not show any databases. You can try to use another piece of software like TablePlus.

Cause 2. You have not enabled port forwarding for MySQL in the Homestead.yaml file

Since Laravel 8’s Homestead version MySQL is not forwarded by default anymore.

That is why you need to add the following code in your Homestead.yaml file.

    - send: 33060 # MySQL/MariaDB
      to: 3306

This also needs to be done for the following services that were previously standard enabled:

  • ngrok UI: 4040 → Forward To 4040
  • MySQL: 33060 → Forward To 3306
  • PostgreSQL: 54320 → Forward To 5432
  • MongoDB: 27017 → Forward To 27017
  • Mailhog: 8025 → Forward To 8025
  • Minio: 9600 → Forward To 9600
  • SSH: 2222 → Forward To 22

Did you solve this with other causes and solutions? Let us know in the comments

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top