Files are locked during deployment

Fix the 'file is in use' error when publishing a new version.

When you upload a new version over FTP and get an error such as file is in use, access denied or the upload of a DLL fails, your application is still running and holding its files open. The operating system does not allow a file to be overwritten while a running program uses it — you would see the same thing on your own computer if you tried to replace the files of a running EXE.

The same applies when you cannot delete a file or folder that your application is using.

Three ways to solve it

1. Use Web Deploy instead of FTP

Web Deploy from Visual Studio stops the application before the upload and starts it again afterwards, so files are never locked. It is also much faster than FTP because it uploads only changed files.

2. Use app_offline.htm

  1. Create the file

    Create a simple file named app_offline.htm (it can contain a short "We'll be right back" message).

  2. Upload it to wwwroot

    Upload app_offline.htm into the wwwroot folder of your website. This special file stops the application.

  3. Wait a few seconds, then upload

    Give the application a few seconds to shut down and upload your files.

  4. Delete app_offline.htm

    When the upload is complete, delete the file. The application starts again with the next request.

More details: Take a site offline with app_offline.htm.

3. Stop the website in the Control Panel

Open the website in the Control Panel and on the Overview page click Stop (it creates app_offline.htm for you) or Restart. Upload or delete your files and start the website again.

Still stuck? Our support team is happy to help.
Ask the community Open a support ticket