Connection Issue between Spring API and Spring Cloud Config Server in Docker Containers on the Same Network

85 Views Asked by At

I'm facing an issue with communication between my Spring API application and the Spring Cloud Config Server, both running in Docker containers on the same network named "guiteste." I'm working on a local project and, for learning purposes, I'm running each container individually (starting with the config server and then the Spring API). I'm choosing not to use Docker Compose at this point, with the intention to set it up later.

Upon starting my Spring API application, I'm receiving the following error:

2023-11-22T22:50:12.283Z INFO 1 --- [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Exception on Url - http://configserver:8000/config:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://configserver:8000/config/config-server/default": Connection refused. Will be trying the next url if available

Both containers are on the same "guiteste" Docker network, and I'm using the container name as the address for the config server.

Here are the relevant configurations:

For the Spring API:

spring.profiles.active=default
spring.application.name=config-server
spring.config.import=optional:configserver:http://configserver:8000/config
management.endpoints.web.exposure.include=*

For the Spring Cloud Config Server:

server.port=8000
spring.application.name=config-server
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=file:///C:/Users/IdeaProjects/config/
spring.cloud.config.server.native.cache=false

Both containers are on the same "guiteste" Docker network.

Versions:

Java: 19 Spring Boot: 3.1.4

Question:

Does anyone have any idea why I'm receiving the "Connection refused" error? I'm open to suggestions on how to resolve this issue and make my Spring API application communicate correctly with the Spring Cloud Config Server in Docker containers.

I appreciate any help in advance!

I've confirmed that both containers are on the same Docker network, and I've verified that the ports are correctly configured. However, I'm still encountering the "Connection refused" error. I'm seeking advice from the community to see if anyone has suggestions on what might be causing this issue or if someone has encountered a similar issue and how they resolved it.

Appreciate any insights or guidance!

0

There are 0 best solutions below