Why do I get connection errors when my front container tries fetching from the backend container in an Azure Container App?

Marko Grdinić 0 Reputation points
2023-07-03T17:12:44.06+00:00

I have a frontend that sends requests to the backend over localhost on a different port. On my local machine it works flawlessly, but when deployed I get connection errors and the fetch fails. It is not a CORS error.

Failed to load resource: net::ERR_CONNECTION_REFUSED
Classifier.tsx:26     POST http://localhost:8001/classify net::ERR_CONNECTION_REFUSED

It looks like that in the browser console. The tricky thing is that on one login it did work, but now it is not working again. I thought that the problem might be that the containers are on different network, but according to Bing Chat, they are supposed to be on the same one. What should I do?

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,606 Reputation points Microsoft Employee
    2023-07-05T15:19:43.8966667+00:00

    @Marko Grdinić Your frontend would make requests from the browser. So, when deployed on a container app, your frontend should make a request to the backend domain instead of localhost.

    The one time it did work, the request likely went to the instance running locally.

    0 comments No comments