Is mysql's port on the host always 3306?
No.
If I bring up the mysql container and map 33060 to 3306
Typically, the default port 3306 in the Docker Container is ported to 33060 on the host.
So. the .env file would have 33060 as the DB_PORT
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using Docker on my Mac. If I bring up the mysql container and map 33060 to 3306. I'm getting a little lost about the msyql port configs. I'm new to Docker and Laravel too.
Should the Laravel .env DB_PORT get 3306 and not the Docker 33060? Is mysql's port on the host always 3306?
I've tested this a bunch of times and it seems like I get the
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = blog_db and table_name = migrations and table_type = 'BASE TABLE') when I'm using the Docker port in the .env but I can connect with TablePlus, which always has the Docker port.
Thanks, just curious about this.
Please or to participate in this conversation.