1

I'm trying to run a full stack application of React JS and Spring Boot in my docker environment. Locally everything works fine. But inside the docker environment, the react js and spring boot application both starts. But I'm getting a connection refused error when I'm trying to establish communication between react and spring boot.

I've added a ProxyPass in my apache2 config file inside the docker environment as follows :- ProxyPass /app-name/ http://0.0.0.0:9090/

Error :- OPTIONS http://localhost:8080/login net::ERR_CONNECTION_REFUSED.
Docker commands used :- Docker command to build the docker image :-
docker build --rm -t <image-name>.

I've exposed the ports required in the docker run command as follows :-
docker run --rm -p 5050:8080 -p 6060:3000 --name <container-name> <image-name>

Docker command to exec inside the container :-
docker exec -it <container-name> /bin/bash

Inside the docker environment, I started the spring boot application using mvn spring-boot:run and started the react application using yarn install followed by yarn start

How do I solve the connection refused error here?

Aravind
  • 256
  • 1
  • 4
  • 17

2 Answers2

1

As per comment ERR_CONNECTION_REFUSED is shown because you are exposing port 5050 on the host and not 8080.

Using http://localhost:5050 will work or you can run the docker command and expose the port on the host as 8080 too

docker run --rm -p 8080:8080 -p 6060:3000 --name <container-name> <image-name>

Bizmate
  • 1,835
  • 1
  • 15
  • 19
0

If you are using separate containers for react app and spring boot app run docker inspect and be shure you are pointing to the Ip address of the container and not to localhost

Alain Plana
  • 152
  • 2
  • 2