Cannot access Spring boot app from Docker host and port after deploying to Docker Containers. Solved!

I recently faced an issue where I deployed our spring boot application Docker environment. Everything worked our perfectly fine like app was getting started in docker env. as per logs.

But when we tried to access the app endpoints from the docker host and port or the load balancer it was the container was unreachable.

We tried to debug the issue by accessing the app inside container using localhost and it surprised us that application endpoints were reachable from inside the container.

Now the issue was that the endpoints were not reachable from container.

The issue could be the pot mapping issue but it was not.

The app was listening to localhost server with address

In our Spring boot file when we added below properties, it fixed the issue.

server.address =

So what is the difference between and

  • is the loopback address (also known as localhost).
  • is a non-routable meta-address used to designate an invalid, unknown or non applicable target (a no particular address placeholder).

In the context of servers, means “all IPv4 addresses on the local machine”. If a host has two ip addresses, and, and a server running on the host listens on, it will be reachable at both of those IPs.

Which means that now our app when started at listens to all container IPv4 now.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s