PermissionDenied errors despite allow-net=* in Deno Deploy
0 reputation · 06 Jun 2022, 12:11 UTC
0 reputation · 06 Jun 2022, 12:11 UTC
When deploying a Deno script to Deno Deploy with the flag allow-net=*, the build logs sometimes show PermissionDenied errors for network requests, even though the same script runs successfully locally with the same flag.
The goal is to determine whether the wildcard pattern is fully supported for network permissions in Deno Deploy’s runtime, or if additional configuration is required to achieve unrestricted outbound access.
Consider the differences between local Deno execution and the Deploy sandbox, the exact version of Deno Deploy being used, and any documented limitations on pattern matching for allow-net.
allow-net=* pattern grant access to all hosts in Deno Deploy, or are certain hosts excluded?allow-net=* is not a Deno Deploy runtime permission grant. Deno Deploy does not use Deno CLI --allow-net flags to control user-script outbound access, so the wildcard neither authorizes all hosts nor is the correct place to configure egress. If a script works locally with --allow-net=* but fails in Deploy with PermissionDenied, the problem is almost certainly the destination or API being outside Deploy’s egress policy, not a missing wildcard.
Confirmed: the Deno CLI treats --allow-net with no allowlist as all network access, and an explicit list is matched per connection. The Deno version installed locally is not the Deno Deploy runtime version; Deploy permission and egress changes are released through the Deploy service or dashboard, not through local deno --version.
Likely explanation: PermissionDenied in Deploy is most often caused by the target or API being outside Deploy’s egress policy. Common exclusions include loopback, RFC1918 private ranges, link-local addresses, and cloud metadata endpoints, which are typically blocked for SSRF protection. Non-HTTP(S) raw sockets and Deno.connect are also commonly restricted. The exact ports, protocols, and current exclusion list depend on the Deploy runtime version and environment.
fetch('https://example.com/') and logs the status. If that succeeds, public HTTPS egress is enabled and the failure is target- or API-specific. If it fails, the issue is account- or deploy-level egress or runtime version.
// Minimal Deploy egress test
export default {
async fetch() {
const res = await fetch("https://example.com/");
return new Response(`status: ${res.status}`);
},
};
deno --allow-net and separately in Deploy for public HTTPS, private/loopback, and non-443 port variants. Do not assume localhost, 127.0.0.1, private RFC1918 addresses, link-local addresses, or metadata endpoints are permitted because they work locally.allow-net=*.--allow-net=* to deployctl, deno.json, or Deploy settings expecting it to override Deploy egress policy; it is not a substitute for an allowed destination.PermissionDenied; isolate by API (fetch, WebSocket, Deno.connect) and by scheme, host, and port before changing code or contacting support.Please provide the exact failing API and target (scheme, host, and port) from the Deploy error stack. This changes the recommendation because a build-time remote import failure, a runtime fetch to a private address, and a raw socket connection each require a different fix.
Use comments to ask for clarification. Post a solution as an answer.
6,510 reputation · 06 Jun 2022, 18:40 UTC
In Deno Deploy the flag allow-net=* is a broad whitelist for publicly routable hosts. The runtime, however, enforces an additional network policy that blocks loopback (127.0.0.1/localhost) and private ranges (10.*, 172.16.*–172.31.*, 192.168.*). If your code targets a local dev server or an internal API, the sandbox will return PermissionDenied even though the flag is set.
To avoid the error:
allow-net list that includes the exact hostname/IP if it is public.Check the runtime release notes for the version you are using; older releases may have stricter rules.