Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

david001's avatar

ports not available mysql

Hi, I am running Laravel sail for the first time. I have valet and mysql already running at port 3306. I want to use Laravel sail as well. Is there any way I can run mysql for sail in different port? I go this error while running: ./vendor/bin/sail up Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:3306 -> 0.0.0.0:0: listen tcp 0.0.0.0:3306: bind: address already in use

How can I use different port for mysql.?

Thanks

0 likes
8 replies
david001's avatar

@Sinnbeck Here is my .env

DB_CONNECTION=mysql
DB_HOST=mysql
FORWARD_DB_PORT=3307
DB_DATABASE=laravel
DB_USERNAME=sail
DB_PASSWORD=password

and I got this error again: Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:80 -> 0.0.0.0:0: listen tcp 0.0.0.0:80: bind: address already in use

david001's avatar

@Sinnbeck Thanks , I have use APP_PORT=8081 in .env and my server is running now. However in browser I got 404 error while accessing localhost. I have / url in my web.php and it opens welcome.blade.php

Mohammad-Ravand's avatar

in windows i had this problem when running mysql

Solution

To solve this, you just need to add your port to the excluded list using these commands:

 net stop winnat

 netsh int ipv4 add excludedportrange protocol=tcp startport=3306 numberofports=1

 net start winnat

after this run

 docker run -p 3306:3306 -d --name mysql-ole-funde -e MYSQL_ROOT_PASSWORD=rootpassword -e MYSQL_DATABASE=mydatabase mysql:latest

working fine.

Please or to participate in this conversation.