Power Automate "Run script" action always returns 502 BadGateway although Office Scripts work in Excel Online

Todt Kevin 10 Reputation points
2026-07-21T09:19:22.1+00:00

Hello,

I am experiencing an issue with the "Run script" action in Power Automate.

The problem started suddenly on 21 July 2026. The flow had been working correctly before, and no relevant changes were made.

Environment

  • Power Automate

Excel Online (Business) OneDrive for Business Excel workbook (.xlsx) Office Scripts

Problem

Every "Run script" action fails with the following error:

502 BadGateway x-ms-datasourceerror: True logs: null

Request ID:

[Moderator note: Personally Identifiable Information removed]   Date: 21 July 2026

However, the same Office Script runs successfully when executed directly in Excel Online.

What I have already tested

To rule out configuration issues, I performed the following tests:

Created a completely new Excel workbook. Created a new Office Script containing only:

function main(workbook: ExcelScript.Workbook) { workbook.getActiveWorksheet().getRange("A1").setValue("Hello"); }

Created a brand-new Power Automate flow containing only: Manual trigger Run script

Result:

The new flow also fails with the same 502 BadGateway error.

Additional troubleshooting

I have also:

Created a new Excel Online (Business) connection. Deleted the old connection. Confirmed that the same Microsoft 365 account is used in both Excel Online and Power Automate. Verified that the workbook is not open anywhere. Tested with multiple different workbooks and Office Scripts. Confirmed that every script works correctly when executed directly from Excel Online.

Why this is critical

My production flow generates PDF documents from an Excel template.

The Office Script is used to force Excel to recalculate formulas before the PDF conversion.

Without the script, the generated PDF sometimes contains outdated data or empty calculated fields, although the Excel workbook itself already contains the correct values.

Therefore, the flow cannot be used reliably without the "Run script" action.

Additional information

Other users are currently reporting the same behavior.

The symptoms are identical:

Office Scripts work correctly in Excel Online. The "Run script" action in Power Automate returns 502 BadGateway. The issue affects newly created flows, newly created workbooks, and newly created Office Scripts.

This suggests that the issue may not be isolated to my tenant.

Question

Is there currently a known issue affecting the Excel Online (Business) "Run script" action in Power Automate?

Are there any tenant settings, service incidents, or additional diagnostics that should be checked?

Any help from Microsoft would be greatly appreciated.

Thank you.Hello,

I am experiencing an issue with the "Run script" action in Power Automate.

The problem started suddenly on 21 July 2026. The flow had been working correctly before, and no relevant changes were made.

Environment

Power Automate

Excel Online (Business)

OneDrive for Business

Excel workbook (.xlsx)

Office Scripts

Problem

Every "Run script" action fails with the following error:

502 BadGateway
x-ms-datasourceerror: True
logs: null

Request ID:

[Moderator note: Personally Identifiable Information removed]  
Date: 21 July 2026

However, the same Office Script runs successfully when executed directly in Excel Online.

What I have already tested

To rule out configuration issues, I performed the following tests:

Created a completely new Excel workbook.

Created a new Office Script containing only:

function main(workbook: ExcelScript.Workbook) {
workbook.getActiveWorksheet().getRange("A1").setValue("Hello");
}

Created a brand-new Power Automate flow containing only:

Manual trigger 

   Run script 
```Result:

The new flow also fails with the same 502 BadGateway error.

## Additional troubleshooting

I have also:

 Created a new Excel Online (Business) connection. 

 Deleted the old connection. 

 Confirmed that the same Microsoft 365 account is used in both Excel Online and Power Automate. 

 Verified that the workbook is not open anywhere. 

 Tested with multiple different workbooks and Office Scripts. 

 Confirmed that every script works correctly when executed directly from Excel Online. 

## Why this is critical

My production flow generates PDF documents from an Excel template.

The Office Script is used to force Excel to recalculate formulas before the PDF conversion.

Without the script, the generated PDF sometimes contains outdated data or empty calculated fields, although the Excel workbook itself already contains the correct values.

Therefore, the flow cannot be used reliably without the "Run script" action.

## Additional information

Other users are currently reporting the same behavior.

The symptoms are identical:

 Office Scripts work correctly in Excel Online. 

 The "Run script" action in Power Automate returns 502 BadGateway. 

 The issue affects newly created flows, newly created workbooks, and newly created Office Scripts. 

This suggests that the issue may not be isolated to my tenant.

## Question

Is there currently a known issue affecting the Excel Online (Business) "Run script" action in Power Automate?

Are there any tenant settings, service incidents, or additional diagnostics that should be checked?

Any help from Microsoft would be greatly appreciated.

Thank you.

**Additional information**

I have found another recent Microsoft Learn question describing the same `502 BadGateway` behavior when running Office Scripts from Power Automate. This suggests that the issue may not be isolated to my tenant.

Can anyone from Microsoft confirm whether there is an ongoing service issue or regression affecting the **Run Script** action?
Microsoft 365 and Office | Excel | For business | Windows

1 answer

Sort by: Most helpful
  1. Rin-L 23,385 Reputation points Microsoft External Staff Moderator
    2026-07-21T10:15:58.1133333+00:00

    Hi @Kevin,

    Thank you for taking the time to provide such a detailed description of the issue and the troubleshooting you've already completed.

    Based on your description, the problem appears to occur specifically when Office Scripts are executed through the Power Automate "Run script" action. Since the same scripts run successfully in Excel Online but fail when triggered from a flow, this seems more related to Power Automate or its integration with Excel Online (Business) than to Excel itself.

    If I'm understanding correctly, this scenario falls more within the scope of Power Automate / Power Platform than the core Excel product. Because your post is currently under the Microsoft 365 and Office | Excel category, I'm concerned that you may not receive the most targeted troubleshooting guidance here. 

    To help you get the most relevant assistance, I'd recommend posting this question in the Microsoft Power Platform Community Forum Thread

    That community is dedicated to Power Automate topics and is often one of the best places to discuss flow execution issues, connector behavior, and service-side errors. The engineers, MVPs, and experienced community members there work with these scenarios regularly and may be able to provide more targeted troubleshooting guidance. They may also be able to confirm whether others are currently experiencing similar 502 BadGateway errors or if there are any known issues affecting the Run script action.

    I apologize for directing you to a different community, but my goal is to help connect you with the right audience as quickly as possible. Given the nature of the issue, the Power Platform community is generally better positioned to investigate and discuss problems related to Power Automate services and connector integrations, which can help avoid spending time on troubleshooting steps that may not apply.

    Thank you for your understanding and patience. I hope you're able to identify the root cause and get your flow running normally again soon.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    Was this answer helpful?

    0 comments No comments

Your answer

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