Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

On Ubuntu 18.04, I'm trying to install Hyperledger Cello, and during the install, I get:

make[2]: Entering directory '/home/julien/cello'
docker-compose -f bootup/docker-compose-files/docker-compose-nfs.yml up -d --no-recreate
WARNING: Found orphan containers (cello-user-dashboard, cello-operator-dashboard, cello-watchdog, cello-keycloak-server, cello-parse-server, cello-dashboard_rabbitmq, cello-mongo, cello-keycloak-mysql, cello-engine) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Starting cello-nfs ... error

ERROR: for cello-nfs  Cannot start service nfs: driver failed programming external connectivity on endpoint cello-nfs (d1be7a4999731983a12df9f1fb6484c7adf669be7edf01c6d962856ed8a6846f): Error starting userland proxy: listen tcp 0.0.0.0:2049: bind: address already in use

ERROR: for nfs  Cannot start service nfs: driver failed programming external connectivity on endpoint cello-nfs (d1be7a4999731983a12df9f1fb6484c7adf669be7edf01c6d962856ed8a6846f): Error starting userland proxy: listen tcp 0.0.0.0:2049: bind: address already in use
ERROR: Encountered errors while bringing up the project.

When trying to figure out which application is using 2049 port, I do:

➜  cello git:(master) ✗ sudo netstat -pna | grep 2049
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
udp        0      0 0.0.0.0:2049            0.0.0.0:*                           -                   
udp6       0      0 :::2049                 :::*                                -                   
unix  3      [ ]         STREAM     CONNECTED     204951   18122/brave --type=  
unix  3      [ ]         STREAM     CONNECTED     204950   5193/brave           

But I get no app name.

I also tried to remove containers with

docker rm -f $(docker ps -aq)

like said in this post, but it didn't work.

How should I do to free this port ?

like image 654
Juliatzin Avatar asked Apr 05 '19 12:04

Juliatzin


People also ask

How do I fix my address already in use?

The Error “address already in use” occurred because some process was already running on the same port. So we can resolve the issue just by killing the process. To stop the process, we need the process ID (PID), which we can fetch using the lsof command.

How do you stop the port which is already in use in docker?

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 . 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> .

How a container gets an internal IP?

By default, the container is assigned an IP address for every Docker network it connects to. The IP address is assigned from the pool assigned to the network, so the Docker daemon effectively acts as a DHCP server for each container. Each network also has a default subnet mask and gateway.


2 Answers

You can try :

docker stop $(docker ps -a -q)
docker ps # again to make sure containers is off
sudo lsof -i tcp:2049 # now you get and list of process running and using 2049 port find and copy PID
sudo kill -9 yout_PID

Now that the 2049 port is killed, then try start containers again...

like image 98
Truong Dang Avatar answered Oct 19 '22 13:10

Truong Dang


It looks as if you have an NFS server running on your host. When you run netstat -p ... as root and you don't see a PID for a port, like this...

tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
udp        0      0 0.0.0.0:2049            0.0.0.0:*                           -                   
udp6       0      0 :::2049                 :::*                                -                   

...it generally means there is a kernel service bound to that port. Disabling the kernel NFS server (assuming that you're not using it) should allow you to run your container.

like image 42
larsks Avatar answered Oct 19 '22 14:10

larsks