ECS service connect not able to connect to backend from frontend application.

1

I have build an Application having backend and frontend which are deployed on ecs fargate. I am using the ecs service connect in the ecs cluster. The frontend is exposed to users via the DNS + ALB whereas the backend does not have any ALB/NLB connectivity. This is the configuration for the frontend and backend: **Frontend: **: container running on port 4200 namespace: myapp.com (client) Backend: container running on port 8080 namespace: myapp.com (client) discoveryName: backend

Now, I am trying to connect to the backend application from frontend application container using the dns name: https://backend.myapp.com:8080

But After trying I am not able to connect to the backend application. and getting the error when checked in the browser developer tool: GET https://backend.myapp.com:8080/index net::ERR_NAME_NOT_RESOLVED

  • I also have the same problem. I can't seem to find a way to fix it.

1 Answer
0

Hi,

I would say that you have built the frontend using a client-side rendering framework (such as React, Vue, or Angular), so it is the browser that makes the request to the backend, not the frontend container, and it is not able to resolve the private DNS.

If so, you should expose the backend to the Internet in the same way as the frontend and call it using a public DNS.

profile picture
EXPERT
answered 8 months ago
  • Hello,

    Actually I am calling the backend service from the front-end code. Only once the frontend is loading it is calling the backend service. Can you please let me know when the should the namespace be used and when not?

  • Hi,

    Since the frontend code is executed on the browser, the backend service must accept external connections from the internet, and AWS recommends using an Elastic Load Balancing for it. Take a look at the link, it explains it very well.

    On the other hand, you could use Amazon ECS Service Connect, Amazon ECS service discovery or AWS App Mesh when you need an application to connect to other applications that run in Amazon ECS services, but I think that is not your case.

  • Hi Mike,

    Thanks for the information. I am using the ecs service connect in my application for both frontend and back-end. They are in the same namespace. With the backend acting as server and frontend as client. Only thing here is that I have both of these services in the private subnet. Only frontend application is available to the internet via the dns and the private ALB.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions