When I run docker-compose up
in my Docker project it failes with the following message:
Error starting userland proxy: listen tcp 0.0.0.0:3000: bind: address already in use
netstat -pna | grep 3000
shows this:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
I've already tried docker-compose down
, but it doesn't help.
This question is related to
ubuntu
docker
ubuntu-14.04
bind
docker-compose
I upgraded my docker this afternoon and ran into the same problem. I tried restarting docker but no luck.
Finally, I had to restart my computer and it worked. Definitely a bug.
Just a side note if you have the same issue and is with Windows:
In my case the process in my way is just grafana-server.exe
. Because I first downloaded the binary version and double click the executable, and it now starts as a service by user SYSTEM
which I cannot taskkill
(no permission)
I have to go to "Service manager" of Windows and search for service "Grafana", and stop it. After that port 3000 is no longer occupied.
Hope that helps.
Changing network_mode: "bridge" to "host" did it for me.
This with
version: '2.2'
services:
bind:
image: sameersbn/bind:latest
dns: 127.0.0.1
ports:
- 172.17.42.1:53:53/udp
- 172.17.42.1:10000:10000
volumes:
- "/srv/docker/bind:/data"
environment:
- 'ROOT_PASSWORD=secret'
network_mode: "host"
`$` sudo service redis-server stop
Does the trick.
I ran into the same issue several times. Restarting docker seems to do the trick
The one that was using the port 8888 was Jupiter and I had to change the configuration file of Jupiter notebook to run on another port.
to list who is using that specific port. sudo lsof -i -P -n | grep 9
You can specify the port you want Jupyter to run uncommenting/editing the following line in ~/.jupyter/jupyter_notebook_config.py:
In case you don't have a jupyter_notebook_config.py try running jupyter notebook --generate-config. See this for further details on Jupyter configuration.
In some cases it is critical to perform a more in-depth debugging to the problem before stopping a container or killing a process.
Consider following the checklist below:
1) Check you current docker compose environment
Run docker-compose ps
.
If port is in use by another container, stop it with docker-compose stop <service-name-in-compose-file>
or remove it by replacing stop
with rm
.
2) Check the containers running outside your current workspace
Run docker ps
to see list of all containers running under your host.
If you find the port is in use by another container, you can stop it with docker stop <container-id>
.
(*) Because you're not under the scope of the origin compose
environment - it is a good practice first to use docker inspect to gather more information about the container that you're about to stop.
3) Check if port is used by other processes running on the host
For example if the port is 6379 run:
$ sudo netstat -ltnp | grep ':6379'
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 915/redis-server 12
tcp6 0 0 ::1:6379 :::* LISTEN 915/redis-server 12
(*) You can also use the lsof command which is mainly used to retrieve information about files that are opened by various processes (I suggest running netstat
before that).
So, In case of the output above the PID
is 915
. Now you can run:
$ ps j 915
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
1 915 915 915 ? -1 Ssl 123 0:11 /usr/bin/redis-server 127.0.0.1:6379
And see the ID of the parent process (PPID
) and the execution command.
You can also run: $ pstree -s <PID>
to a visual display of the process and its related processes.
In our case we can see that the process probably is a daemon (PPID is 1) - In that case consider running:
A) $ cat /proc/<PID>/status
in order to get a more in-depth information about the process like the number of threads spawned by the process, its capabilities, etc'.
B) $ systemctl status <PID>
in order to see the systemd unit that caused the creation of a specific process. If the service is not critical - you can stop and disable the service.
4) Restart Docker service
Run: sudo service docker restart
.
5) You reached this point and..
Only if its not placing your system at risk - consider restarting the server.
Check docker-compose.yml
, it might be the case that the port is specified twice.
version: '3'
services:
registry:
image: mysql:5.7
ports:
- "3306:3306" <--- remove either this line or next
- "127.0.0.1:3306:3306"
This helped me:
docker-compose down # Stop container on current dir if there is a docker-compose.yml
docker rm -fv $(docker ps -aq) # Remove all containers
sudo lsof -i -P -n | grep <port number> # List who's using the port
and then:
kill -9 <process id>
(macOS) or sudo kill <process id>
(Linux).
Source: comment by user Rub21.
On my machine a PID was not being shown from this command netstat -tulpn
for the in-use port (8080), so i could not kill it, killing the containers and restarting the computer did not work. So service docker restart
command restarted docker for me (ubuntu) and the port was no longer in use and i am a happy chap and off to lunch.
I resolve the issue by restarting Docker.
maybe it is too rude, but works for me. restart docker service itself
sudo service docker restart
hope it works for you also!
In my case it was
Error starting userland proxy: listen tcp 0.0.0.0:9000: bind: address already in use
And all that I need is turn off debug listening in php storm
I had the same problem. I fixed this by stopping the Apache2 service on my host.
I had same problem,
docker-compose down --rmi all
(in the same directory where you run docker-compose up)
helps
UPD: CAUTION - this will also delete the local docker images you've pulled (from comment)
Before it was running on :docker run -d --name oracle -p 1521:1521 -p 5500:5500 qa/oracle I just changed the port to docker run -d --name oracle -p 1522:1522 -p 5500:5500 qa/oracle
it worked fine for me !
docker-compose down --rmi all
and then restart your computer
I was getting the below error when i was trying to launch a new conatier- listen tcp 0.0.0.0:8080: bind: address already in use.
Solution: netstat -tulnp | grep 8080
[[email protected] (aws_main) ~]# netstat -tulnp | grep 8080 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 12749/java [[email protected] (aws_main) ~]#
kill -9 12749
Then try to relaunch the container it should work
A variation of @DmitrySandalov's answer: I had tomcat/java running on 8080, which needed to keep going. Looked at the docker-compose.yml file and altered the entry for 8080 to another of my choosing.
nginx:
build: nginx
ports:
#- '8080:80' <-- original entry
- '8880:80'
- '8443:443'
Worked perfectly. (The only wrinkle is the change will be wiped if I ever update the project, since it's coming from an external repo.)
For Linux/Unix:
Simple search for linux utility using following command
netstat -nlp | grep 8888
It'll show processing running at this port, then kill that process using PID (look for a PID in row) of that process.
kill PID
Source: Stackoverflow.com