Chrome blocks a request from a public site to a local address
Look for and connect to any device on your local networkShort answer
Chrome now treats a request from a public page to localhost or a private IP as a Local Network Access request. The user must grant permission in a prompt, the page must be a secure context, and company policy can pre-allow or block it. Check the permission and the policy first.
Fix it fast
1Find out which cause you have
Check what the page is and what it calls. Print whether the page is a secure context, and look at the exact target address of the failing request in the Network panel.
console.log(window.isSecureContext, location.origin)2Match what you see, then jump to its fix
- 1
The request fails at once with no prompt, or the prompt text mentions finding and connecting to devices on the local network.The user denied or never saw the permission promptFix - 2
The page URL starts with http:// and is not localhost.The page is not a secure contextFix - 3
The console reports a mixed content block instead of a permission error.Mixed content blocks an http target from an https pageFix - 4
The request only fails on managed work computers, and the permission cannot be changed.An office policy blocks or does not pre-allow the siteFix
- 1
What does the error look like?
Look for and connect to any device on your local networkfetch from a public https page to http://localhost or 192.168.x.x fails only in recent Chrome
Cause 1 of 4
The user denied or never saw the permission prompt
1Check
Chrome gates local-network and loopback requests behind a permission prompt, replacing the older preflight-based Private Network Access design.
console.log(window.isSecureContext)2Fix
Choose Allow when the prompt appears, and reset the site permission in Chrome if it was denied earlier. In your code, make the request after a user action so the prompt can appear.
document.querySelector('#connect').addEventListener('click', async () => {
const res = await fetch('http://localhost:8765/status');
console.log(await res.json());
});3Verify
The request now completes, and the status shows in the console.
curl http://localhost:8765/statusConfirmed by developer.chrome.com
Cause 2 of 4
The page is not a secure context
1Check
Only secure contexts may make private network requests, and Chrome enforces this since Chrome 94.
console.log(window.isSecureContext)2Fix
Serve the page over HTTPS.
# serve the site from https://, for example behind a TLS-terminating proxy3Verify
isSecureContext prints true.
console.log(window.isSecureContext)Confirmed by developer.chrome.com
Cause 3 of 4
Mixed content blocks an http target from an https page
1Check
A request to a local http address from an https page is mixed content unless it is exempt. Private IP literals and .local names are exempt. A public domain name that resolves to a local address is not.
console.log(new URL('http://192.168.0.1/ping').hostname)2Fix
Tell Chrome the target is local with the targetAddressSpace fetch option.
fetch('http://example.com/ping', { targetAddressSpace: 'local' });3Verify
The mixed content message disappears and the permission prompt shows.
console.log('retry the fetch and read the console')Confirmed by developer.chrome.com
Cause 4 of 4
An office policy blocks or does not pre-allow the site
1Check
Chrome has enterprise policies for this: LocalNetworkAllowedForUrls for local network targets and LoopbackNetworkAllowedForUrls for the local device, An admin controls them.
# ask your admin which Chrome policies are set for local network access2Fix
Ask the admin to add the site's origin to the Allowed policy for the target type.
# policy LocalNetworkAllowedForUrls, value: https://example.com3Verify
Restart Chrome, retry the request and check that no prompt or block appears.
# retry the request from the pageConfirmed by chromeenterprise.google
How do I stop it coming back?
- Make local requests from a button click, not at page load, so users see the prompt in context.
- Test local-device features in current Chrome as well as the version your users run.
- Document the allow policy for the admins of customers who use a local agent.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Web apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fixWeb apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Apollo Client is blocked by CORS when the GraphQL server runs on AWS Lambda
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Apollo Server does not set CORS for you when it runs behind a framework or integration, and on Lambda that layer is API Gateway.
5 causes, each with a fixWeb apps
A POST to a Google Apps Script web app returns 405 or a CORS error
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Apps Script web apps run doPost for POST and doGet for GET, and the Apps Script guides describe no other entry points.
3 causes, each with a fix