Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker & Postgres: Failed to bind tcp 0.0.0.0:5432 address already in use

Problem

I'm trying to start postgres in a docker container on my Mac, but I keep getting the following error message

docker: Error response from daemon: driver failed programming external connectivity on endpoint postgres (8392b9e5cfaa28f480fe1009dee461f97e82499726f4afc4e916358dd2d2f61e): Error starting userland proxy: Failed to bind tcp 0.0.0.0:5432 address already in use.

I have postgres installed locally, but I stopped it and running

pg_ctl status 

returns

pg_ctl: no server running

I've ran the following to check what's running on 5432

lsof -i tcp:5432 

&

netstat -anp tcp | grep 5432 

and nothing is running on the port.

Versions

Mac - OS X El Capitan Version 10.11.2

PostgreSQL - 9.5

Docker - Docker version 1.12.0-rc2, build 906eacd, experimental

like image 365
user3147424 Avatar asked Jul 07 '16 15:07

user3147424


People also ask

What's Docker used for?

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.

What is Docker vs Kubernetes?

Docker is a company which provides a set of tools for building and sharing container images, and running containers at both small and large scale. Kubernetes is a tool which manages (“orchestrates”) container-based applications running on a cluster of servers.

What is Docker vs VM?

The main distinction between these two technologies is that VMs run as virtual environments on the same hardware, whereas Docker runs on virtualizations of the same operating system.

What is Docker in simple term?

In simple terms, Docker is a software platform that simplifies the process of building, running, managing and distributing applications. It does this by virtualizing the operating system of the computer on which it is installed and running. The first edition of Docker was released in 2013.


1 Answers

If lsof -i :5432 doesn't show you any output, you can use sudo ss -lptn 'sport = :5432' to see what process is bound to the port.

Proceed further with kill <pid>

like image 106
Jamie Avatar answered Sep 27 '22 18:09

Jamie