Docker 6 - Error Docker Compose in Linux
Error Message
- The error message is displayed when I tried to start a docker container that uses the port
5432
, but the port is already in use.
1
2
3
ERROR: for <APP-NAME> Cannot start service postgres: driver failed programming external connectivity on endpoint <APP-NAME> (6469a63bb19d545db5b2b3852cb5704e8065d0ae1e71fead778d14a8cac39299): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
ERROR: for postgres Cannot start service postgres: driver failed programming external connectivity on endpoint <APP-NAME> (6469a63bb19d545db5b2b3852cb5704e8065d0ae1e71fead778d14a8cac39299): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use
Solution
- To get the process id of the process that is using the port 54, use the following command:
1
sudo ss -lptn 'sport = :5432'
- You will need to input your
sudo
password to run the command. - The output will look like this:
1
2
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 200 127.0.0.1:5432 0.0.0.0:* users:(("postgres",pid=934,fd=6))
- Then use the following command to kill the process:
1
sudo fuser -k 5432/tcp
- The output will look like this:
1
5432/tcp: 934
- Then check if the port is free:
1
sudo ss -lptn 'sport = :5432'
- If you see this output, then the port is free:
1
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
This post is licensed under CC BY 4.0 by the author.