The “Not allowed to load local resource” error in Chrome on Windows 11 blocks web pages from opening files stored on your computer (like images, PDFs, or videos) via a file:// link. The fix is to either move the files to a local web server, use Chrome’s command-line flag to allow local file access, or embed the file as a data URL. Below are the exact steps for each method, plus the background on why Chrome blocks this in the first place.
Why Chrome Blocks Local Files
Chrome (like most modern browsers) treats every web page as a separate security origin. When a page served from http:// or https:// tries to load a resource using file://, Chrome sees that as a cross-origin request and blocks it. This prevents malicious websites from reading files on your hard drive without your permission. The error message “Not allowed to load local resource” is Chrome’s way of enforcing the same-origin policy, which is a core security feature of the web platform.
Method 1: Use a Local Web Server (Recommended)
The cleanest and most reliable fix is to serve your files over HTTP. This avoids the security restriction entirely and works for all file types. You can run a simple server using Python (if installed) or a lightweight tool like Node.js.
- Open the folder containing your files in File Explorer.
- Click the address bar, type
cmd, and press Enter to open Command Prompt in that folder. - Type
python -m http.server 8000and press Enter. (If Python isn’t installed, usenpx http-serverif you have Node.js.) - Open Chrome and go to
http://localhost:8000. You’ll see a directory listing of your files. - Click the file you want to open. It will load normally without the error.
This method works for any file type, including HTML pages that reference local images or scripts. It also mimics a real web environment, which is useful for testing.
Method 2: Use Chrome’s Command-Line Flag
Chrome has a hidden flag that disables the local file restriction. This is a quick fix, but it’s not recommended for everyday browsing because it weakens security. Use it only if you need to open local files frequently and understand the risks.
- Close all Chrome windows and processes (check the system tray for background Chrome icons).
- Press
Win + R, typecmd, and press Enter to open Command Prompt. - Type the following command and press Enter:
start chrome --allow-file-access-from-files - Chrome will open with the flag active. Now try loading your local file again.
Note: This flag only works for the session in which you launched it. If you close Chrome and reopen it normally, the restriction returns. Also, the flag may not work if Chrome is already running, so ensure it’s fully closed first.
Method 3: Embed the File as a Data URL
If you control the HTML page that references the local file, you can embed the file’s content directly into the page using a data URL. This avoids the need for a server or flag. For example, to embed an image:
- Convert the image file to a base64 string. You can use an online tool or a small script.
- In your HTML, replace the
srcattribute withdata:image/png;base64,....(including the base64 string). - Open the HTML file directly in Chrome. The image will load because it’s part of the page itself.
This method works for small files (a few hundred KB) but becomes impractical for large files because the HTML file size increases significantly. It’s best for single images or small scripts.
Common Scenarios and Quick Alternatives
Sometimes the error appears in specific situations where a simpler workaround exists:
- Dragging a file into Chrome: If you drag an image or PDF from File Explorer into Chrome, it usually opens fine. If it doesn’t, try using
Ctrl+Oto open the file dialog and select the file manually. - HTML file referencing local resources: If you have an HTML file that uses relative paths (e.g.,
images/photo.jpg), opening the HTML file directly (file:///C:/path/to/file.html) should work without any error. The error only occurs when an http page tries to access a file path. - Chrome extensions: Some extensions that read local files may trigger this error. If you’re using one, check its settings or switch to a different extension.
Security Considerations
Using the command-line flag (--allow-file-access-from-files) disables a key security boundary. While it’s fine for testing a static site locally, you should never use it while browsing the web. A malicious website could potentially read files from your computer if you have the flag active. Always close and restart Chrome without the flag after you’re done. The local server method is safer because it only exposes the specific folder you chose to serve, and only to your own machine.
Frequently Asked Questions
Why does this error happen even when I open an HTML file directly?
If you open an HTML file directly (double-click it), Chrome loads it via file://. That HTML file can reference other local files (like images or scripts) using relative paths, and those will load fine. The error only occurs when an http page tries to load a file resource. So if you see the error on a file you opened directly, check that your relative paths are correct and that the files exist.
Does this error happen in other browsers?
Yes, Firefox and Edge also block local file access from web pages, but they may show different messages. Firefox, for example, shows “Access to the file was denied.” The underlying security reason is the same. Edge, being Chromium-based, shows the exact same message as Chrome.
Can I disable this restriction permanently in Chrome?
There’s no official setting to permanently disable it. The command-line flag only works for the session it was launched with. You could create a shortcut that always launches Chrome with the flag, but that’s not recommended for security reasons. The local server method is the permanent and safe solution.
Will this error affect my ability to view PDFs downloaded from the internet?
No. PDFs you download are stored locally, but Chrome opens them using its built-in PDF viewer, which reads the file directly and doesn’t trigger the restriction. The error only appears when a web page tries to load a local file via a link or script.
Is there a way to allow local file access only for specific sites?
No, Chrome doesn’t offer per-site permissions for local file access. The restriction is global. If you need to allow a specific site to access local files, you’d have to use a local server and serve the files from that server, then access them via http://localhost.
Why does this error happen when I use a local development tool like Live Server?
Live Server (and similar tools) already serve your files over HTTP, so they shouldn’t trigger this error. If you see it, it’s likely because your code has an absolute path like file:///C:/... instead of a relative path. Change it to a relative path (e.g., images/photo.jpg) and it will work.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- 0x800f0922 Update Failed: Fixes That Work
- How to Record Webcam on Windows PC
- Rename Built-in Administrator Account in Windows 10
- Enable or Disable Photos in Spotlight Search on iPhone
- Bond Redemption at Maturity: What Investors Need to Do
- How to Fix Secure Boot Not Enabled in Windows 11 and 10