Forum Discussion

bergen288's avatar
bergen288
Helper IV
1 year ago
Solved

BadGateway error with SQL connector in Power Apps

Below is the screenshot of my SQL connector in Power Apps.  The same credential works fine in Power BI SQL connection, but it gives me following error in Power Apps.  What's wrong with it and how to fix it?  By the way, I have the free trial premium license of Power Apps.  Thanks in advance.

{
"error": {
"code": 502,
"source": "msmanaged-na.azure-apim.net",
"clientRequestId": "e9c897af-a683-4a7c-b75c-6508e71ac881",
"message": "BadGateway",
"innerError": {
"status": 502,
"message": "Microsoft SQL: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provide<truncated>

Session ID: fa2ce54e-4005-4c07-b1bc-3e3ea862d65a

 

 

 

7 Replies

  • Expiscornovus's avatar
    Expiscornovus
    Most Valuable Professional

    Hi bergen288,


    Just to double check. That address looks like it is a privately hosted database and not an Azure SQL database, correct?

     

    As far as I understood the Connect Directly (Cloud services) option was for Azure SQL databases. But I might be wrong.

     

    And when you say the Power BI SQL connection was working what do you exactly mean? Did you connect to the database from the Power BI desktop application on your local network?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you Expiscornovus 

    Hi, bergen288 

    Make sure that the name/field/table is referenced correctly, if it is misreferenced it will trigger the issue:

    Solved: bad gateway error 502 powerapps - Power Platform Community

    Here's the Power Apps Connect to Azure SQL Server documentation, confirm that your steps are OK:

    Connect to SQL Server from Power Apps - Power Apps | Microsoft Learn

     

     

    Common issues and resolutions for Power Apps - Power Apps | Microsoft Learn

     

     

     

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • bergen288's avatar
      bergen288
      Helper IV

      Jianpeng:

       

      I will take a look of your links.  Thanks.

      • Anonymous's avatar
        Anonymous
        Not applicable

        HI, bergen288 

        Thank you very much for your reply. Your description and screenshots, which really prove that there is no problem with your credentials. You'll need to check Power Apps' limits on the data source, as I provided earlier, to see if there are any statements that are causing a 502 error when sending a query.

        This may be a correct way to solve the problem.

        Power Automate throwing 502 BadGateway error. - Microsoft Community

         

         

        Best Regards

        Jianpeng Li

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Yes, it's privately hosted SQL database and not an Azure SQL database.  With "The same credential works fine in Power BI SQL connection", I meant to use same credential to connect SQL table as screenshot below:

     

  • I asked wrong question because of wrong option.  This time, I choose "Connect using on-premises data gateway" instead of "Connect directly".  However, there is no gateway installed and if I click "install gateway", it brings me to microsoft Power Apps website: Microsoft Power Apps – Build Apps with AI | Microsoft.  There is nothing about gateway installation.  If I click "Sign in", then it brings me to my Power Apps home page.  Because of no installed gateway, "Connect" icon is greyed out.

    Actually, my company won't allow me to install any software on my laptop without approval while it is extremely hard to get something approved.  There is a setup of SQL gateway for JWPKSQLEP02.corp.checkfree.com in my Power BI web service as shown below.  My new question is how to connect to SQL in Power Apps with the SQL gateway in my Power BI web service?