Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use

121,170

Solution 1

Probably you have already a MySQL service running in port 3306. You should close it first.
Then try to end docker-compose down and restart it with docker-compose up.
Remember also to change the permissions after you add a file in your project (like dartisan make:auth) with dpermit

UPDATE: since you have changed the port to "8084" you should go to localhost:8084
If you see the apache default then you probably are browsing another server since dockervel is build upon nginx.
You have also probably have some gaps on Docker. Don't mix your local storage with docker storage. /var/www in a container is different than your local /var/www. in docker-compose.yml you mount the local ~/dockervel/www to containers /var/www.
I would suggest that you start all over again and revert the changes you've made to your apache server. Shut it down, you don't need it. Dockervel will provide you with an NginX server in a container.

Solution 2

I had the same problem and

sudo netstat -nlpt |grep 3306

showed me the PID and which service it was started by (mysgld). Whenever I tried to kill the PID then it was started again. But the problem was fixed when I stopped the service by

sudo service mysql stop

Notice that you will have to use mysql and not mysqld.

I hope that this will do it for you - I was able to run docker-compose up without any problems

Solution 3

Try to kill all the processes using the port 3306:

sudo kill `sudo lsof -t -i:3306`

Then, run your docker containers:

sudo docker-compose up

Solution 4

My fix for this issue was to go into

docker-compose.yml

and change ports: -3306:3306 to ports: -3307:3306 then run this command again:

docker-compose up

Solution 5

On Ubuntu, running this command will stop your mysql from running for your docker container to work:

sudo service mysql stop  

Then, if your apache2 is running, you need to stop the service especially when you want to work with nginx:

sudo service apache2 stop

Then, you can run your docker-compose up -d ... command

Share:
121,170
moonlight
Author by

moonlight

Updated on December 29, 2021

Comments

  • moonlight
    moonlight over 2 years

    I have to make Laravel app and to deliver a Dockerfile, but I'm really stuck with this. Before that I had a nightmare wile installing laravel on my machine.

    I'm trying to get dockervel image and following the steps here: http://www.spiralout.eu/2015/12/dockervel-laravel-development.html

    But when I run dartisan make:auth it gives this error below:

    **ERROR:** for dockervel_mysql_1  **Cannot restart container** c258b418c03cbd6ec02c349c12cf09403f0eaf42fa9248019af7860d037d6474: **driver failed programming external connectivity on endpoint dockervel_mysql_1** (da3dd576458aa1fe3af7b539c48b9d61d97432cf5e9ee02d78562851f53981ae): E**rror starting userland proxy: listen tcp0.0.0.0:3306: bind: address already in use.**
    

    I have tried to Change the default port in the docker-compose.yml

       ports:
         - "8084:80"
    

    Still nothing, also tried to stop apache2 (service apache2 stop) on my machine ,also tried docker-compose restart and removing docker container dockervel_mysql_1.

    I have to mention that I have already one Laravel proj. in /var/www/laravel.

    Please help!

  • moonlight
    moonlight almost 8 years
    $service mysqld stop gives me this : $mysqld: unrecognized service About the second solution is it complicated as it sounds?
  • BMitch
    BMitch almost 8 years
    You can probably do an ls /etc/init.d to find the service name for mysql. Changing the mysql published port is the same steps you changed for port 80, you just need to do this for 3306 instead of 80.
  • moonlight
    moonlight almost 8 years
    Look at my new comment below !I answered.
  • Abdel Hidalgo
    Abdel Hidalgo about 4 years
    This is the current easy solution
  • Adarsh Rajput
    Adarsh Rajput over 3 years
    We should have solution which support local mysql, stopping local mysql can not be solution.
  • Adarsh Rajput
    Adarsh Rajput over 3 years
    We should have solution which support local mysql, stopping local mysql can not be solution. Guiding new comers to wrong thing.
  • Adarsh Rajput
    Adarsh Rajput over 3 years
    We should have solution which support local mysql, stopping local mysql can not be solution
  • Spiral Out
    Spiral Out over 3 years
    @AdarshRajput in this case you should not start mysql from container and link the other services with your local mysql. Or at least use another port for one of them. You cannot have two services using the same port.
  • Adarsh Rajput
    Adarsh Rajput over 3 years
    @SpiralOut- You are right (technically). BUT here you should tell how to use different port in docker OR local mysql + might be OP's docker setup is duplicate & have no local instance. See the main issue from OP: [have tried to Change the default port in the docker-compose.yml] || still 3306 in use, means OP might be doing setting at wrong place.
  • Spiral Out
    Spiral Out over 3 years
    @AdarshRajput you are also right, this might be another way to handle this, but then again it should not be on nginx's port but mysql's port. If you tested it and it works for you then upvote @cece answer bellow
  • swyx
    swyx over 3 years
    got this error running this: netstat: t: unknown or uninstrumented protocol
  • Lazac92
    Lazac92 over 3 years
    So underrated answer, however this is the good way when you want to use it beside an another mysql service.
  • scotty
    scotty over 2 years
    I would vote for this one as it allow coexistence of multiple mysql service/instances, get the current issue solved won't affect anything else especially those unknow things.
  • guyaloni
    guyaloni over 2 years
    Great, this is what solved me the problem. There is any way to avoid mysql service start on boot?
  • Gloria Chen
    Gloria Chen almost 2 years
    This brutal way works for me!