Fix Office Online Viewer Cannot Open Localhost DOCX Files
Question details
The user is unable to open or preview a DOCX file hosted on localhost using the Microsoft Office Online Viewer service.

- Product
- Microsoft Office Online Viewer
- Device & OS
- not provided
- Scenario
- Attempting to preview a local DOCX document during web development by passing a localhost URL to the Office Online Viewer.
- Observed behavior
- The Office Online Viewer fails to display the document because Microsoft's cloud servers cannot reach or retrieve files from a local network address.
Ensure you have access to a public web hosting server, cloud storage provider, or a secure tunneling service to host your DOCX file externally.
Host the DOCX File on a Publicly Reachable Server
Move the document from localhost to a server with a public URL so Microsoft's viewer service can successfully retrieve and render it.
Microsoft Office Online Viewer is a cloud-based web service. When you provide it with a document link, Microsoft's external servers attempt to download the file to generate the preview. Because 'localhost' or private IP addresses only point to your local machine, the viewer service cannot access them.
Upload your DOCX file to a publicly accessible web server, an AWS S3 bucket, or use a publicly shared direct link from a cloud storage service.
Verify that your public server is using an SSL certificate. Office Online Viewer requires the document to be served over a secure HTTPS connection.
Open a browser on a different network (like a mobile device on cellular data) and navigate to the file URL to ensure it automatically downloads without any login prompts.
Pass the new, publicly accessible HTTPS URL to the Office Online Viewer parameter (e.g., https://view.officeapps.live.com/op/view.aspx?src=[YOUR_PUBLIC_URL]).

Use a Local Tunneling Tool During Development
Use tools like ngrok to temporarily expose your localhost environment to the internet for testing purposes.
Open Local DOCX Files Directly with WPS Office
If you just need to view and edit DOCX files on your computer without exposing them to public servers, WPS Office is the perfect solution. It completely eliminates the need for cloud viewers by handling local documents natively.
- 1. Download WPS Office: Download and install the free version of WPS Office from the official website.
- 2. Locate your local file: Find the DOCX file you are hosting on your localhost folder.
- 3. Open and edit instantly: Right-click the file, select 'Open with', and choose WPS Office to view and edit your document immediately.

Frequently Asked Questions
Can Office Online Viewer read private network IP addresses?
No. Office Online Viewer requires the document to be hosted on a publicly reachable domain or IP address. Private network IPs (like 192.168.x.x or 10.x.x.x) are blocked and inaccessible from Microsoft's cloud servers.
Why does Office Online Viewer say 'Document not found' when my URL is correct?
Even if the URL is correct on your machine, the 'Document not found' error occurs if the URL is not publicly accessible over the internet, is blocked by a firewall, or requires authentication to access.
Is HTTPS required to use Office Online Viewer?
Yes. For security reasons and cross-origin policies, Microsoft Office Online Viewer generally requires the source document to be hosted on a secure server using an HTTPS connection.
How can I view DOCX files locally in a web app without public URLs?
If you cannot expose documents to the internet, you must rely on JavaScript-based client-side rendering libraries (like mammoth.js) or direct the user to open the file locally using a desktop application like WPS Office.




