Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"driver failed programming external connectivity on endpoint" (1.7.0-rc1) #3277

Closed
jamshid opened this issue Apr 6, 2016 · 300 comments
Closed

"driver failed programming external connectivity on endpoint" (1.7.0-rc1) #3277

jamshid opened this issue Apr 6, 2016 · 300 comments

Comments

@jamshid
Copy link

@jamshid jamshid commented Apr 6, 2016

I'm pretty sure this was working on docker-compose 1.7.0-rc1 before I installed the latest Docker for Mac beta, which upgraded to docker 1.11.0-rc3. I'm trying to get the socat service to run on port 172.17.0.1:8123, so that it's available to docker builds. My real yml uses an environment variable for the IP address, but it happens even when hardcoded.

ERROR: for socat_httpcache  driver failed programming external connectivity on endpoint test_socat_httpcache_1 (5d973ed559d63a5561b715248f797a336915a44960b5e32e622ac8349b16e5d2): Error starting userland proxy: failed to bind port: Unix.Unix_error(Unix.EADDRNOTAVAIL, "bind", "")
version: '2'
services:
  httpcache:
    restart: always
    image: clue/polipo
    command: proxyAddress=0.0.0.0 allowedClients=0.0.0.0/0 disableIndexing=false disableServersList=false
    mem_limit: 500m
    memswap_limit: 500m
    volumes:
      - /var/cache/polipo

  socat_httpcache:
    restart: always
    hostname: POLIPO1
    image: bobrik/socat
    mem_limit: 50m
    command: TCP-LISTEN:8123,fork,reuseaddr TCP:httpcache:8123
    depends_on:
      - httpcache
    ports:
      - "172.17.0.1:8123:8123"

verbose.txt

@aboch
Copy link

@aboch aboch commented Apr 6, 2016

@jamshid
Can you post the o/p of sudo netstat -nlp | grep 8123. Thanks.

@jamshid
Copy link
Author

@jamshid jamshid commented Apr 6, 2016

My mac says -p requires an argument, so I think this is what you want:

$ sudo netstat -nl -p tcp  | grep 8123
(nothing)
$ sudo netstat -nl -p tcp  | head    # to confirm mac output is what you expect
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4       0      0  192.168.2.4.52918      216.58.194.34.80       ESTABLISHED
tcp4       0      0  192.168.2.4.52917      23.199.236.147.80      ESTABLISHED
tcp4       0      0  192.168.2.4.52916      192.229.163.25.443     ESTABLISHED
tcp4       0      0  192.168.2.4.52915      192.229.163.175.80     ESTABLISHED
...
$ docker ps -a | grep 8123
7baf5b2ec0eb        clue/polipo               "polipo proxyAddress="   26 minutes ago      Up 12 minutes                  8123/tcp            test_httpcache_1
3fea15e3d5b4        clue/polipo               "polipo proxyAddress="   33 minutes ago      Up 19 minutes                  8123/tcp            buildenv_httpcache_1

@bezelga
Copy link

@bezelga bezelga commented Apr 29, 2016

same thing happening to me.

@leeahoward
Copy link

@leeahoward leeahoward commented May 3, 2016

I am getting the same issue when restarting using docker-compose up. In my case it's an nginx proxy service that fails to start. Must be related to the Docker for Mac beta. It started after I installed the beta and hasn't happened after switching back over to Virtualbox.

docker-compose version 1.7.0, build 0d7bf73
Docker version 1.11.0, build 4dc5990

@elghazal-a
Copy link

@elghazal-a elghazal-a commented May 4, 2016

I encouner the same error when I try to start my stack using docker-compose. All the containers start correctly except one (consul). I'm getting this error

ERROR: for consul driver failed programming external connectivity on endpoint devas_consul_1 (6ceba32c51cb70b354f 2f4b68d173ca97a65d6a0bfd308d3137e2a7069abd1b6): Error starting userland proxy: Failed to bind: EADDRNOTAVAIL

I'm sure it has something to do with my docker version beta for mac.

docker-compose -v docker-compose version 1.7.0, build 0d7bf73

I'm using the last docker beta version for mac

`
docker version
Client:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Wed Apr 27 00:34:20 2016
OS/Arch: darwin/amd64

Server:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 8b63c77
Built: Fri Apr 29 14:13:26 2016
OS/Arch: linux/amd64
`

@zhangbanger
Copy link

@zhangbanger zhangbanger commented May 5, 2016

Following the above message, I get Error starting userland proxy: Failed to bind: EADDRINUSE.
Confused as to where the conflict is where none existed before

@mattgi
Copy link

@mattgi mattgi commented May 7, 2016

How does one "release" the port that is in use so that compose can bring up the container again? First time it happened, I waited for a minute or so and it worked on second attempt. Second time, its been about an hour. Docker compose kill, down, rm --all, etc. and something still has a hold of it.

@mattgi
Copy link

@mattgi mattgi commented May 7, 2016

@elghazal-a
Copy link

@elghazal-a elghazal-a commented May 13, 2016

I figure out what the problem is about, the container (consul) causing the issue has this binding port 172.17.0.1:53:8600/udp. I replaced it with 53:8600/udp and it's working now. I didn't understand yet why the first binding doesn't work. BTW, How can I know the bridge ip address?

@rsilveira65
Copy link

@rsilveira65 rsilveira65 commented May 30, 2016

Hello, I had the same problem with Docker version 1.11.1 on Mac OSX.
ERROR: for nginx driver failed programming external connectivity on endpoint managercentralapp_nginx_1 (e11d19ee8f486a2e12c9c87802dca7ea5f541f026645f69e338e94732ac1eb56): Error starting userland proxy: Failed to bind: EADDRINUSE

@madjam002
Copy link

@madjam002 madjam002 commented Jun 20, 2016

I too am getting this after upgrading to Docker 1.12-rc2, not sure if this is the right place to post this.

Client:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   906eacd
 Built:        Fri Jun 17 20:35:33 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   906eacd-unsupported
 Built:        Fri Jun 17 21:12:28 2016
 OS/Arch:      linux/amd64
 Experimental: true

@madjam002
Copy link

@madjam002 madjam002 commented Jun 21, 2016

Full error:

Error response from daemon: driver failed programming external connectivity on endpoint xxx_xxx_1 (xxx): Bind for 0.0.0.0:2224 failed: port is already allocated

netstat:

tcp6       0      0 :::2224                 :::*                    LISTEN      9083/docker-proxy

@deg
Copy link

@deg deg commented Jun 22, 2016

I'm seeing this sporadically. Retrying the command after a minute usually "fixes" the problem.
This is after moving to Docker for Mac yesterday.

$ docker version
Client:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   906eacd
 Built:        Fri Jun 17 20:35:33 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   a7119de
 Built:        Fri Jun 17 22:09:20 2016
 OS/Arch:      linux/amd64
 Experimental: true

@kausik93
Copy link

@kausik93 kausik93 commented Jun 29, 2016

I've also been getting the same error as you guys. I believed it was because nginx was binding it ports that were already taken up but I don't think so now. Did anyone find any solutions to this? :)

@briankelleher
Copy link

@briankelleher briankelleher commented Jul 6, 2016

+1 Same error on mac

@joemewes
Copy link

@joemewes joemewes commented Jul 6, 2016

I had this happening after a move to Docker for Mac, but after stopping and removing All containers after the move, restarting docker, recreating container etc etc. It was fixed.

I had this again today after an update of Docker for Mac , but repeating the above scenario fixed. I assume the port (and "other" things) I'm assigning to particular containers is not being released until completely cleaned up.

eg:

ERROR: for nginx driver failed programming external connectivity on endpoint dev_nginx (4c340c55f7402c7b265803ea64541ebdf8613f4b43dfa816001d27bdc4f513b3): Error iptables FORWARD: Another app is currently holding the xtables lock; waiting (1s) for it to exit... ERROR: Encountered errors while bringing up the project.

@krim
Copy link

@krim krim commented Jul 7, 2016

+1 have the same problem on mac

@leifdejong
Copy link

@leifdejong leifdejong commented Jul 7, 2016

@TuningGuide MacBook Pro (15-inch, Late 2011), 2.2 GHz Intel Core i7, 8GB 1333 MHz DDR3
Running Node 4.4.7 extended to support Ember CLI. Setup is below:

FROM node:4.4.7

# expose ember-cli ports
EXPOSE 4200 35729 49152

# install ember-cli dependencies
RUN npm install -q -g ember-cli
RUN npm install -q -g bower
RUN npm install -q -g phantomjs-prebuilt

# install watchman
# http://ember-cli.com/user-guide/#watchman
RUN \
  git clone https://github.com/facebook/watchman.git &&\
  cd watchman &&\
  git checkout v3.5.0 &&\
  ./autogen.sh &&\
  ./configure &&\
  make &&\
  make install

Ran with mounted volume of the ember-cli files using 'ember serve' as the command.

@luki3k5
Copy link

@luki3k5 luki3k5 commented Jul 8, 2016

+1 same problem on the mac with docker for mac

@TuningGuide
Copy link

@TuningGuide TuningGuide commented Jul 8, 2016

Please stop sending +1, as it spams all subscriber inboxes. Either use the emoticons (smiley on the right of each comment) or at least give your full setup, version numbers and so on. Thx

@miraage
Copy link

@miraage miraage commented Jul 8, 2016

➜  ~ docker info
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 2
Server Version: 1.12.0-rc3
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 21
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.14-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.954 GiB
Name: moby
ID: GZAT:26TX:PYCM:KKNA:JSWY:AMEL:RQYI:O23B:QGSQ:WBVB:3Q7E:XDPJ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 18
 Goroutines: 30
 System Time: 2016-07-08T17:41:26.03558348Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
➜  ~ cat docker-compose-local.yml
version: '2'
services:
  cache:
    image: redis
    command: redis-server --appendonly yes
    ports:
      - "6379:6379"
  db:
    image: postgres:9.4
    ports:
      - "5432:5432"
    volumes:
      - ./tmp/dump.gz:/tmp/dump.gz
      - ./tmp/dump.sh:/docker-entrypoint-initdb.d/dump.sh
    environment:
      POSTGRES_DB: dbname
      POSTGRES_USER: dbuser
      POSTGRES_PASSWORD: dbpass

Got next errors:

ERROR: for cache  driver failed programming external connectivity on endpoint carsaver_cache_1 (253054ef6864bdcb5377bd1690173fa352021d505dc05c3aafecf66b02c0b73d): Error starting userland proxy: write /port/tcp:0.0.0.0:6379:tcp:172.18.0.2:6379/ctl: errno 526

ERROR: for db  driver failed programming external connectivity on endpoint carsaver_db_1 (8a5990bd06a50d87c7db96de84367bb01b71c971d5a4b9e578fea7d75d893d59): Error starting userland proxy: write /port/tcp:0.0.0.0:5432:tcp:172.18.0.3:5432/ctl: errno 526
ERROR: Encountered errors while bringing up the project.

@miraage
Copy link

@miraage miraage commented Jul 8, 2016

Found solution for people with same error as I shown above.
I was previously using Docker Toolbox, but I did not delete Virtualbox. It was using my ports so I can not start. After complete removing VirtualBox, docker-compose worked awesome.

@aanand @dnephin please, add to Getting Started a warning like explained above.

@FrenchBen
Copy link

@FrenchBen FrenchBen commented Jul 8, 2016

@miraage happy to hear you solved your issue.
I didn't have your volume data+dump.sh but did a quick compose without issues:

Creating driverfailed_cache_1
Creating driverfailed_db_1
Attaching to driverfailed_cache_1, driverfailed_db_1

@jamshid Why are you specifying an IP for socat (not familiar with it)? How are you using it?
Doing a docker-compose up without the IP I don't have any issues:

Creating socat_httpcache_1
Creating socat_socat_httpcache_1
Attaching to socat_httpcache_1, socat_socat_httpcache_1
docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
f2e3b3767982        bobrik/socat        "socat TCP-LISTEN:812"   2 seconds ago       Up 1 seconds        0.0.0.0:8123->8123/tcp   socat_socat_httpcache_1
43dbd35629e0        clue/polipo         "polipo proxyAddress="   3 seconds ago       Up 2 seconds        8123/tcp                 socat_httpcache_1

If your goal is for your http_cache to talk to the socat container, why not put them on the same network and be done with it?

version: '2'
services:
  httpcache:
    restart: always
    image: clue/polipo
    command: proxyAddress=0.0.0.0 allowedClients=0.0.0.0/0 disableIndexing=false disableServersList=false
    mem_limit: 500m
    memswap_limit: 500m
    volumes:
      - /var/cache/polipo
    networks:
      - socatnet

  socat_httpcache:
    restart: always
    hostname: POLIPO1
    image: bobrik/socat
    mem_limit: 50m
    command: TCP-LISTEN:8123,fork,reuseaddr TCP:httpcache:8123
    depends_on:
      - httpcache
    networks:
      - socatnet
networks:
  socatnet:

@marcelmfs
Copy link

@marcelmfs marcelmfs commented Jul 11, 2016

Well, I'm using docker engine 1.11.2 in centos7 in a Continuous Build/Integration flow to automate tests and as far as I can tell, eventually this error pops up even though no container is running (while re-deploying a specific version of the whole service stack). Also it seems related to the fact that sometimes docker engine gets an error on trying to cleanup after the removal of running containers, and some iptables rules might be kept allocating network ports for some reason, maybe related to moby/moby#23371 (comment) - but I'm still not sure about that.

djs55 added a commit to djs55/vpnkit that referenced this issue Jul 11, 2016
…ases

Previously we lacked a function to convert from Uwt.error to Unix.error.
Happily uwt.0.0.3 contains such a useful error converting function, so
we use it.

When a port forward is requested, use `Lwt.catch` to handle the exception
at the top-level and pretty-print the error message for the expected cases

- EADDRINUSE: the port was already 'allocated'
- EADDRNOTAVAIL: the interface IP was not found (probably it exists in a
  VM but not on the host)
- EPERM: insufficient privileges to bind a privileged port

The pretty-printing is intended to match the output of `docker` on
regular Linux.

This is related to [docker/compose#3277]

Signed-off-by: David Scott <dave.scott@docker.com>
djs55 added a commit to djs55/vpnkit that referenced this issue Jul 12, 2016
…ases

Previously we lacked a function to convert from Uwt.error to Unix.error.
Happily uwt.0.0.3 contains such a useful error converting function, so
we use it.

When a port forward is requested, use `Lwt.catch` to handle the exception
at the top-level and pretty-print the error message for the expected cases

- EADDRINUSE: the port was already 'allocated'
- EADDRNOTAVAIL: the interface IP was not found (probably it exists in a
  VM but not on the host)
- EPERM: insufficient privileges to bind a privileged port

The pretty-printing is intended to match the output of `docker` on
regular Linux.

This is related to [docker/compose#3277]

Signed-off-by: David Scott <dave.scott@docker.com>
@igorrKurr
Copy link

@igorrKurr igorrKurr commented Jul 12, 2016

I've had pretty same issue, with Docker for Mac, running postgresql container. So, for me it was caused by postgres running on same port on host system as port specified in my compose config file. Pretty obvious thing, but could be helpful for someone I guess.
Thanks for cool tool. 👍

@marcosalberto
Copy link

@marcosalberto marcosalberto commented Jul 12, 2016

I had a similar problem Docker for Mac running nginx container, my port 80 was being used by apache (native). I used telnet and netstat to see the running service.

@surajadh
Copy link

@surajadh surajadh commented Jul 12, 2016

For me it was squid, I stopped squid and didn't see that anymore. So I think it may have to do with whatever is taking up the port and if we force docker to map that port.

@tsantos84
Copy link

@tsantos84 tsantos84 commented Jul 9, 2020

@tsantos84 Docker will be running inside a VM when you're using Docker for Mac.
Try the following (I haven't tested this though):

* `docker rm -f $(docker ps -aq)` (will remove all of your containers)

* `docker network rm $(docker network ls -q)` (will remove all of your networks)

* `docker run --rm -v /var/lib/docker/network/files:/network busybox rm /network/local-kv.db`

Then restart Docker for Mac and you should be good to go +1

Thank you! It helped me to quickly solve the problem.

Hi @fede-r1c0, I don't know why you mentioned me and probably you wanted to mark another user. Anyway, I'm happy you solve your problem. 👍

@douglasrosa0110
Copy link

@douglasrosa0110 douglasrosa0110 commented Jul 22, 2020

@jamshid
Can you post the o/p of sudo netstat -nlp | grep 8123. Thanks.

and sudo service {nameOfService} stop

@chief93
Copy link

@chief93 chief93 commented Aug 5, 2020

I've encountered same behavior, but for overriding of the service, by creating the docker-compose.override.yml. The files used:

docker-compose.yml:

version: '3.2'
services:
  app:
    build:
      context: ./
    ports:
     - "8000:80"
    volumes:
     - ./:/app

docker-compose.overrride.yml:

version: '3.2'
services:
  app:
    ports:
     - "8001:80"

That gives me following UNEXPECTED error:

ERROR: for my_app_1  Cannot start service app: driver failed programming external connectivity on endpoint my_app_1 (9235372fe636fba32be67f9f101a3432139c691a41fc6d207e53c98e25139a29): Bind for 0.0.0.0:8000 failed: port is already allocated

ERROR: for app  Cannot start service app: driver failed programming external connectivity on endpoint my_app_1 (9235372fe636fba32be67f9f101a3432139c691a41fc6d207e53c98e25139a29): Bind for 0.0.0.0:8000 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

I expected that ports directive in docker-compose.override.yml will override same in the docker-compose.yml (the 8000 port on my machine is already allocated by another application, that's why I tried the overriding) but this does not happen, which is wrong and seems like a bug.

OS: Windows 10
Docker: 19.03.12, build 48a66213fe

@maxvonhippel
Copy link

@maxvonhippel maxvonhippel commented Sep 28, 2020

In my case the issue was due to running consul locally but also in a container.

@salSB
Copy link

@salSB salSB commented Oct 8, 2020

For me it was firewall related, on CentOS 7, run your docker normally when working, then stop firewalld or just restart it, now try to restart that docker container, fails with this error. Restart docker service and try again... works fine.

@FanYikang
Copy link

@FanYikang FanYikang commented Oct 20, 2020

I've encountered same behavior.
This solved my issue on centos7:
ps -ef | grep docker
kill the "...dockerd -H fd:// --containerd=/run/containerd/containerd.sock" process

@JackOfSpade
Copy link

@JackOfSpade JackOfSpade commented Oct 23, 2020

Found this thread, and none of the above helped me.

I am running Ubuntu and I had to use:

sudo service docker restart

I tried prune and all the other commands and docker was sure it had nothing running, but after restarting the service, it all started working again.

THANK YOU! HOLY FK, I SPENT A WHOLE DAY TRYING TO FIX THIS.
THE YEAR IS 2020, THAT'S 4 YEARS AND THIS PROBLEM STILL EXISTS. WTF

@Slisarenko
Copy link

@Slisarenko Slisarenko commented Dec 9, 2020

/etc/init.d/redis-server stop
I'm using docker, in my case, It helped me

@vakenbolt
Copy link

@vakenbolt vakenbolt commented Dec 22, 2020

Just had encountered the same issue complaining about a Postgres container. Curiously, exiting Docker for Mac (desktop) did not solve the trick, I had to actually select Restart from the menu and that fixed the issue.

@nagy135
Copy link

@nagy135 nagy135 commented Jan 24, 2021

just read through this thread, and what seems to be the best answer in 2021 is to restart docker service (sv restart docker, systemctl restart docker, etc ....)
That indeed makes it work again, but why this is happening is unclear still from this thread

@kris-nova
Copy link

@kris-nova kris-nova commented Jan 30, 2021

run;

systemctl restart docker

happened to be kernel networking debugging at the same time - a previous container instance was the culprit

iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8081 -j DNAT --to-destination 172.17.0.2:2342 ! -i docker0: iptables: No chain/target/match by that name.

was what gave it away when iptables couldn't DNAT on the docker0 interface

@lucatsf
Copy link

@lucatsf lucatsf commented Feb 4, 2021

I got it by doing the command
sudo systemctl stop httpd or sudo /etc/init.d/apache2 stop

@mortensassi
Copy link

@mortensassi mortensassi commented Feb 22, 2021

I got it by doing the command
sudo systemctl stop httpd or sudo /etc/init.d/apache2 stop

same here. Reinstalled PHP on my Ubuntu 20.04 and had a simple test running. Seems like apache runs per default on port 80:

# $ sudo netstat -nlp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      848/apache2         

@Daniel-M
Copy link

@Daniel-M Daniel-M commented Apr 9, 2021

I'm experiencing the same problem with:

Docker version 20.10.5, build 55c4c88
docker-compose version 1.29.0, build 07737305

I'm unable to restart my services since docker-compose says they are already running, which is true because docker-compose brings those containers up and fails telling they are already up. Restarting the service systemctl restart docker.service and systemctl restart docker.socket does nothing unless I restart --yes, restart-- the OS

@mortensassi
Copy link

@mortensassi mortensassi commented Apr 9, 2021

@Daniel-M you could try and find the docker process ps aux | grep docker and kill -9 <THE PID> - did you make sure no other process is occupying that port?

@Daniel-M
Copy link

@Daniel-M Daniel-M commented Apr 9, 2021

@Daniel-M you could try and find the docker process ps aux | grep docker and kill -9 <THE PID> - did you make sure no other process is occupying that port?

I made 100% sure nothing else was using those ports. The odd thing was the following sequence

  • docker ps -a shows no containers
  • docker-compose up fails starting a couple of containers since the ports are allegedly in use
  • docker ps -a now shows the failed containers running, the ones docker-compose reported as failed to start
  • Only those containers are running, so the project is useless

As for killing docker I did not tried that, I relied on systemctl, but will try that next time

After I restarted my computer today to continue working, docker-compose did not failed (as expected) but I'm not willing to try, have to keep working on things, I wouldn't be surprise it this happen gain, I will provide screnshots or even a video of the console

Thank you for your suggestion @mortensassi

@dmtanner
Copy link

@dmtanner dmtanner commented Apr 14, 2021

I was having this same issue w/ docker. docker service restarts and OS restarts even would not fix it. I am on Ubuntu 20.04.

when running docker-compose up kept getting this error:
ERROR: for redis_1 Cannot start service redis: driver failed programming external connectivity on endpoint redis_1 (e55df4eefb70eh58dd408ac3a05385345a2eaa15a19aec555b629b91a77f0aeb): Error starting userland proxy: listen tcp6 [::]:5055: socket: address family not supported by protocol

and this warning:
WARNING: Host is already in use by another container

docker-compose version 1.29.0, build 07737305
I tried with docker version 20.10.6 and I also tried 19.03.15 and they both have the same problem.

The only way I was able to fix this was by rolling back docker to 19.03.9.

@davidcsi
Copy link

@davidcsi davidcsi commented Apr 15, 2021

@renepardon
Copy link

@renepardon renepardon commented Apr 16, 2021

I was having this same issue w/ docker. docker service restarts and OS restarts even would not fix it. I am on Ubuntu 20.04.

when running docker-compose up kept getting this error:
ERROR: for redis_1 Cannot start service redis: driver failed programming external connectivity on endpoint redis_1 (e55df4eefb70eh58dd408ac3a05385345a2eaa15a19aec555b629b91a77f0aeb): Error starting userland proxy: listen tcp6 [::]:5055: socket: address family not supported by protocol

and this warning:
WARNING: Host is already in use by another container

docker-compose version 1.29.0, build 07737305
I tried with docker version 20.10.6 and I also tried 19.03.15 and they both have the same problem.

The only way I was able to fix this was by rolling back docker to 19.03.9.

I had the same problem today on my Ubuntu 20.04. This error just appeared. I think it was because of a recent update.

$ docker -v
Docker version 20.10.6, build 370c289

$ docker-compose -v
docker-compose version 1.25.0, build unknown

Additional information:

WARNING: Host is already in use by another container

important note: HOST is already in use.

Checking with ps and netstat the corresponding ports are free but on my system I have ipv6 disabled. Looks like Docker is trying to use ipv6 for whatever reason from now on??

Error starting userland proxy: listen tcp6 [::]:6379: socket: address family not supported by protocol

@wsw70
Copy link

@wsw70 wsw70 commented Apr 17, 2021

@dmtanner thank you very much for your comment.

After upgrading packages on my system and rebooting I was stuck with docker trying to connect to IPv6 despite being disabled on my system.

Downgrading helped, the command is (in case someone is desperate and in a hurry)

apt install docker-ce=5:19.03.15~3-0~ubuntu-bionic
systemctl stop docker
systemctl start docker

EDIT: I did not realize that the issue was opened in 2016...

In my case the problem is definitely with IPv6: up to and including version 19 the fact that it is disabled on my system was handled correctly, I upgraded today to 20.something and random issues with containers not starting because of that happened.
Downgrading fixed everything (there were no changes in the configuration of the containers).
I did not have messages about the "HOST being already used ...", just

ERROR: for 0aa9cd2e88ae_mqtt Cannot start service mqtt: driver failed programming external connectivity on endpoint mqtt (7123295e1d2a17d53a88c9847db30deac6888dcd6a27f7901b0b8a3dedff2cb6): Error starting userland proxy: listen tcp6 [::]:8883: socket: address family not supported by protocol

@austinrivas
Copy link

@austinrivas austinrivas commented Apr 22, 2021

Ubuntu 20, Docker version 20.10.6, build 370c289

Updated docker and now getting this error, rolled back and resolved the issue.

Definitely and issue with the current docker release.

Cannot start service postgres: driver failed programming external connectivity on endpoint tradebinder_postgres_1 (8333460cee3dffb87b736b2af62c06ba0ffef7b28ca765ee686a9681d38ef66d): Error starting userland proxy: listen tcp6 [::]:5432: socket: address family not supported by protocol

@reneolivo
Copy link

@reneolivo reneolivo commented Apr 27, 2021

MacOS user here. This problem usually happens randomly to me. No processes on the troubled port. Not even a single container, no vbox virtual machine up, nothing.

Restarting didn't fix anything. Updating and restarting the Docker service using the Docker Desktop app fixed the issue. Not sure if this will fix the issue in the future.

@graveszhang
Copy link

@graveszhang graveszhang commented May 14, 2021

Ubuntu 20.04 here, the error message was

Error response from daemon: driver failed programming external connectivity on endpoint nginx (b05d13ec7f7c76e6cb4e1bbec142a5655d875477c081e71371179cda80efadb0): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
Error: failed to start containers: nginx

To resolve this issue, I used sudo netstat -plant | grep 80 and found that apache is using the port, and then I just typed sudo systemctl stop apache2.service.

Hope it helps.

@austinrivas
Copy link

@austinrivas austinrivas commented May 14, 2021

The same error is thrown when the port is occupied, but for users experiencing this issue who have confirmed the port is unoccupied it is more complicated.

The underlying issue is due to a breaking change introduced in Docker version 20.10.6 that breaks networking for devices that don't have ipv6 enabled.

The only solution is rolling back to 20.10.5 until a fix is published.

For additional info see here docker/for-linux#1233

Instructions on how to rollback and blacklist release 20.10.6 docker/for-linux#1233 (comment)

@CodingNagger
Copy link

@CodingNagger CodingNagger commented Jun 9, 2021

Unfortunately running into the same issue today, running a Postgres container. Port in use error but the port isn't used, ran all the diagnostic commands I could find to verify this. Restarting the Mac didn't change anything. No way to rollback to the previous version, however, killing docker and restarting it with the following command seems to have fixed the issue:

killall Docker && open /Applications/Docker.app

@snogrammer
Copy link

@snogrammer snogrammer commented Jun 10, 2021

@CodingNagger same for me. I just updated to 3.4.0 and seems to be working for the time being, but keeping your command ready since force killing it seems to be the only way to get my containers to run.

@robin-blanchard
Copy link

@robin-blanchard robin-blanchard commented Jun 15, 2021

Ran into this issue today. Tried many of the commands above, nothing worked.
Looking into netstat showed no process running on the same port. Launching the container on another port led to the same error.
Rebooting fixed the issue.

@kokizzu
Copy link

@kokizzu kokizzu commented Jun 18, 2021

ran this issue today
same port (9000) used by another program/docker
stopping all other docker on docker ps and the service (probably systemctl stop clickhouse-server) works

@ocdC0d3r
Copy link

@ocdC0d3r ocdC0d3r commented Oct 18, 2021

I had the same issue which was caused by my local php8 instance (local apache2 server took over the address)
sudo systemctl stop apache2.service Solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet