Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
bergen288
Helper IV
Helper IV

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

 

bergen288_1-1729262496283.png

 

 

1 ACCEPTED SOLUTION
v-jianpeng-msft
Community Support
Community Support

Hi, @bergen288 

You can install the local gateway standard mode (enterprise gateway) to use the same gateway in Power BI and Power Apps:

Manage an on-premises data gateway in Power Apps - Power Apps | Microsoft Learn

vjianpengmsft_0-1730196382871.png

 

 

 

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.

View solution in original post

7 REPLIES 7
v-jianpeng-msft
Community Support
Community Support

Hi, @bergen288 

You can install the local gateway standard mode (enterprise gateway) to use the same gateway in Power BI and Power Apps:

Manage an on-premises data gateway in Power Apps - Power Apps | Microsoft Learn

vjianpengmsft_0-1730196382871.png

 

 

 

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
Helper IV
Helper IV

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.

bergen288_0-1729869637271.png

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?

bergen288_1-1729870197527.png

 

 

bergen288
Helper IV
Helper IV

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:

bergen288_0-1729620969063.png

 

v-jianpeng-msft
Community Support
Community Support

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

vjianpengmsft_1-1729474480148.png

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

vjianpengmsft_2-1729474624316.png

 

 

vjianpengmsft_0-1729474364437.png

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.

 

Jianpeng:

 

I will take a look of your links.  Thanks.

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.

vjianpengmsft_0-1729651202619.png

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.

Expiscornovus
Solution Sage
Solution Sage

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?



Happy to help out 🙂

I share #PowerAutomate and #SharePointOnline content on my Blog, Bluesky profile or Youtube Channel

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.