# Fix "file is locked for shared use" in Power Automate

> For the full documentation index, see https://250highstreet.com/llms.txt

> Power Automate says a file is locked for shared use. See who holds the lock, then retry in a loop, check the check-out status, or run the flow later.

Short answer: this error means a person or another flow has the file open or checked out when your flow tries to change it. Close or check in the file, then add a retry policy to the action (Settings, Retry policy, fixed or exponential) or a Do until loop with a Delay, and limit the trigger's concurrency to 1 so two runs do not hit one file.

This guide is for a cloud flow in Power Automate ([https://make.powerautomate.com](https://make.powerautomate.com)) that works on a file in a SharePoint library. The same message can show up on Move file, Delete file, Update file properties, Create file and Excel Online actions. Find out who holds the file first. The extra check for each action is under "Which action failed". The steps are a way to start, not a guarantee for every setup.

## What the message means

Your flow asked SharePoint to change a file, and the file was not free. Something else already had it. The flow does not wait politely. The action fails, and the rest of the run stops or skips.

Think of a paper folder on a desk. If someone is writing in it, you cannot write in it at the same moment. The flow is the second person.

## Who or what can hold the file

Our advice, not a Microsoft rule: look at these five places in this order.

1.  A person has the file open in Excel, Word or PowerPoint.
2.  A person checked the file out in the library.
3.  Another flow is working on the same file at the same time.
4.  A sync or a background job has the file for a short time.
5.  A flow step that used the Excel Online (Business) connector. Microsoft's Excel connector page says: "An Excel file may be locked for an update or delete up to 6 minutes since the last use of the connector."

Start with the first two. If your flow wrote to the same Excel file a few minutes earlier, check item 5.

## Step 1. Look at the failed run

1.  Open [https://make.powerautomate.com](https://make.powerautomate.com) and select My flows.
2.  Open your flow and select the failed run. Exact names may differ on your screen.
3.  Select the red action. Open its Outputs and read the error text.
4.  Write down the file name and the time of the failure.

The time matters. If the failures happen at the same time every day, look for a person or a job that is busy at that time.

## Step 2. Check if the file is checked out

When a person checks out a file, the library marks it as theirs. Microsoft's help page on checking out files says a checked-out file "won't be available to your colleagues until you check the file back in". A flow is not a colleague, but it is also not the person who has the file, so an action that changes the file can be refused.

To check the status:

1.  Open the library in SharePoint from [https://www.microsoft365.com](https://www.microsoft365.com). Exact names may differ.
2.  Look for a small icon to the right of the file name. Microsoft's page says: "When the file is checked out, a small icon appears to the right of the file name."
3.  Point at the file name. Microsoft's page says you can then see details about the file, "including the name of the person who has it checked out."
4.  Ask that person to check the file in.

Microsoft's page also says: "If you have permission, you can check a file back in that was checked out by someone else." Use this only when the person has gone and you own the file. Our advice, not a Microsoft rule: ask first when you can, because changes they have not checked in may not be kept.

## Step 3. Check if someone has the file open

If the file is not checked out, a person may just have it open. Ask your team who is in the file. Our advice, not a Microsoft rule: put the file name and the flow time in a message, so people know what to avoid.

If the same few people always have the file open, the file is shared by too many hands. See "[Excel file locked by another user: the fix and the long-term fix](/guides/excel-file-locked-by-another-user/)".

## Step 4. Make the flow try again

A flow that fails once and stops is fragile. A flow that waits and tries again handles a short lock. There are two tools.

The first is the retry policy. Microsoft's error handling page says: "Retry policy in flow settings allows you to retry an action at either fixed or exponential intervals." Microsoft says: "Exponential retry policies are preferred because they can extend the retry period over time and increase the chances of successfully completing the action." You set it in the settings of the action: the initial interval and the maximum retry count. Microsoft's limits page lists up to 90 retry attempts and a one day maximum delay as the settings limits, and a default of up to 12 retries for the Medium and High performance profiles. Our advice, not a Microsoft rule: set an exponential policy on the file action, then test it with a locked file.

The second is a loop that you build. One way to start:

1.  Add an Initialize variable action. Name it Done, set Type to Boolean and Value to false.
2.  Add a Do until action. Set it to stop when Done is equal to true.
3.  Inside it, put the action that changes the file.
4.  After that action, add a Set variable action that sets Done to true. Set its Configure run after to Is successful.
5.  Add a Delay action of a few minutes. Set its Configure run after to Has failed on the file action, so it only waits when the file was locked.
6.  Set the Do until limits so it cannot run forever.

Microsoft's limits page says for Until iterations: "Default: 60" and "Maximum: 5,000". Pick a number that fits your wait. For example, 6 tries with a 5 minute wait means the flow gives up after about 30 minutes.

Microsoft's error handling page says the Run after settings let you "specify what should happen if an action fails, times out, is skipped, or is successful". That is the setting used in steps 4 and 5.

## Step 5. Say what happens when the loop gives up

A loop must have a way out. Our advice, not a Microsoft rule: after the Do until, add a Condition. If Done is still false, send a short message to the flow owner with the file name and a link to the run. Microsoft's error handling page suggests logging errors in "a SharePoint list or other storage solution" and sending a notification. Without this step, a flow can fail with nobody told.

For the full list of flow errors and what they mean, see "[Error: An action failed. No dependent actions succeeded.](/guides/power-automate-action-failed-no-dependent-actions-succeeded/)".

## Which action failed

Open the failed run and note which action has the red mark. Each action needs one extra check.

- Move file or Delete file: the file must be free when the action runs, so use Step 2 and Step 3, then the retry in Step 4.
- Update file properties: the same. Our advice, not a Microsoft rule: when your flow is triggered by a change to the same file, add a Sent or Done Yes/No column with its default value set to No, have the flow check that it is No before it updates the item, and set it to Yes in that same update. Without that guard, the flow's own update can start another run.
- Create file: Our advice, not a Microsoft rule: if the file name already exists and someone has it open, the same lock can appear. Use a name that is unique per run.
- Excel Online (Business) actions: Microsoft says "An Excel file may be locked for an update or delete up to 6 minutes since the last use of the connector." Wait, or add a Delay before the next action on that file.

## Step 6. Run the flow when nobody is in the file

If the lock is always a person at their desk, change when the flow runs. A scheduled flow can run early in the morning or late at night. Our advice, not a Microsoft rule: pick a time outside working hours for every person who uses the file, including people in other time zones.

If the schedule does not fire when you set it, see "[Scheduled flow did not run at the set time](/guides/power-automate-scheduled-flow-not-running/)".

## Step 7. Do not let two flows work on one file at once

If two runs of the same flow can overlap, they can lock each other out. Microsoft's limits page says for Concurrency Control: "off by default". Turning it on is a setting in the trigger, and Microsoft's page lists "1 to 100" concurrent runs when it is on. Our advice, not a Microsoft rule: set the degree of parallelism to 1, so a second run waits until the first one is done with the file. Microsoft's page also says: "Turning on Concurrency Control can't be undone without deleting and re-adding the trigger." Read that before you change it.

Our advice, not a Microsoft rule: an easier first fix is to make sure no two flows write to the same file. Give each flow its own file or its own list.

## What to avoid

- Do not remove the lock by force as the first step. Find out who has the file.
- Do not set a loop with no limit. It can run for a long time and use up your daily actions.
- Do not set a delay of a few seconds and call it done. A person with a file open can hold it for much longer.
- Do not use a file as a database. A spreadsheet that many people and many flows write to will run into locks more than a list does. Our advice, not a Microsoft rule: if this keeps happening, move the data to a SharePoint list. See "[Replace a spreadsheet tracker with a SharePoint list](/guides/replace-spreadsheet-with-sharepoint-list/)".
- Do not ignore failed runs. Check the run history each week.

## When to get help

You can build all of this yourself in Microsoft 365. If you would rather have it built and tested for your team, I do that. A tracker like this is a fixed price: \$5,000 for one, built in 2 weeks. See "[What a SharePoint tracker costs to build](/guides/what-a-sharepoint-tracker-costs/)". Bring one example of the problem to a free call.

I am Al Davies. I run 250 High Street LLC and build SharePoint trackers and Power Automate flows for operations teams. I work remotely. The first call is free, and I will not try to sell you anything.

See trackers I built: [Tools I built](/portfolio/)

## FAQ

### How do I fix "file is locked for shared use" on Move file or Delete file?

Find who has the file open or checked out, ask them to close or check it in, then run again. Add a retry policy so a short lock does not stop the run.

### How do I fix it on Update file properties?

Same cause and same fix. Our advice, not a Microsoft rule: add a Yes/No guard column with its default value set to No, check that it is No, and set it to Yes in the same update, so the flow's own update does not start another run.

### Why does an Excel file stay locked after my flow runs?

Microsoft says: "An Excel file may be locked for an update or delete up to 6 minutes since the last use of the connector."

### How do I fix it on Create file?

Check that nobody has a file with that name open, and use a unique name per run. Our advice, not a Microsoft rule: add a retry policy to the action as well.

### How many times should the loop try?

Our advice, not a Microsoft rule: pick a total wait that fits your work, such as 30 minutes, and then send a message to a person. Microsoft's limits page lists the Until default as 60 and the maximum as 5,000.

## Sources

- [Microsoft Learn, Employ robust error handling](https://learn.microsoft.com/en-us/power-automate/guidance/coding-guidelines/error-handling)
- [Microsoft Learn, Limits of automated, scheduled, and instant flows](https://learn.microsoft.com/en-us/power-automate/limits-and-config)
- [Microsoft Support, Check out, check in, or discard changes to files in a SharePoint library](https://support.microsoft.com/en-us/sharepoint/documents-and-library/check-out-check-in-or-discard-changes-to-files-in-a-sharepoint-library)
- [Microsoft Learn, Excel Online (Business) connector](https://learn.microsoft.com/en-us/connectors/excelonlinebusiness/)

## Related guides

- [Excel file locked by another user: the fix and the long-term fix](/guides/excel-file-locked-by-another-user/)
- [Send Power Automate emails from a shared mailbox](/guides/power-automate-send-email-from-shared-mailbox/)
- [Scheduled flow did not run at the set time](/guides/power-automate-scheduled-flow-not-running/)
- [Loop workspace or component not showing in Teams: what to check](/guides/microsoft-loop-workspace-not-showing-in-teams/)

Source: https://250highstreet.com/guides/power-automate-file-is-locked-for-shared-use/
