Docker Compose Port is already Allocated

Are you getting this error using Docker Compose?

Bind for 0.0.0.0:5432 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

In this article, We will show you how you can resolve this error

The cause of this error is docker container was still running in the background with the allocated port

In our case, we have tried to run Postgres with port 5432

Then we tried to stop the docker first using the following command

Stop Docker

docker stop $(docker ps -a -q)

Remove Containers

then we removed the containers using the following command

docker rm $(docker ps -a -q)

Run the Docker

After running the container using the following command there is no Port already allocated error as shown in the screenshot.

docker-compose up

Thank you!

๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘

If you liked this post, please support our work!

Written by

We teach & develop for startups

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store