Access localhost server inside the hosted app on app-service

Gorthi Sai Sri Sindhuja 60 Reputation points
2023-11-01T11:04:25.83+00:00

Hello,

I have a flask app hosted in my azure app service. I'm trying to access a localhost server in my app but I'm getting internal server error. Is there a way to work with this?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,301 Reputation points Moderator
    2024-01-18T23:23:48.2966667+00:00

    Hi Gorthi Sai Sri Sindhuja ,As Lex mentioned, we will need more info to help answer your question specifically. But generally, the issue you’re experiencing is likely due to the fact that “localhost” within the context of an Azure App Service refers to the local environment of the App Service itself, not your local machine<sup>.</sup> This means that if you’re trying to access a server running on your local machine from your Flask app hosted on Azure, it won’t be able to find it, hence the internal server error. A few things to consider:

    1. You could expose your local server to the internet using a service like ngrok, and then update your Flask app to use the public URL provided by ngrok instead of localhost.
    2. If your Flask app and the server it’s trying to access need to communicate frequently, it might be more efficient to host both on Azure. You could use an Azure Virtual Machine or another App Service to host your server.
    3. Azure supports Hybrid Connections, which can be used to access a TCP endpoint (like a server) on your local network from an App Service.

    Grace

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.