deno: listenAndServeTLS - Uncaught PermissionDenied: Permission denied (os error 13)

deno 1.0.0 v8 8.4.300 typescript 3.9.2

I’m trying to run the code snippet shown in the documentation for listenAndServeTLS.

I’m running the script like this: deno run --allow-net --allow-read server.js

I getting this error:

error: Uncaught PermissionDenied: Permission denied (os error 13)
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listenTls ($deno$/ops/tls.ts:67:10)
    at listenTls ($deno$/tls.ts:51:22)
    at serveTLS (https://deno.land/std/http/server.ts:313:20)
    at listenAndServeTLS (https://deno.land/std/http/server.ts:338:18)
    at file:///home/user/test/server.js:10:1

I’m using a real certificate. I’ve set permissions on the cert-files to 777:

chmod 777 localhost.crt
chmod 777 localhost.key

Yet, I’m still getting the same error. When I google this error, I come across Rust related threads.

Ultimately, the only way I could get past this error was to run the script using sudo: sudo /home/user/.deno/bin/deno run --allow-net --allow-read server.js

Is this a bug, or expected behavior?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (4 by maintainers)

Most upvoted comments

It’s expected behavior - I guess you have some odd ownership/permissions going on. That said, the error message would be improved by including corresponding path…

I was fighting and fighting with this error:

error: Permission denied (os error 13)

during this command:

setuidgid $MY_USER deno cache --import-map ./import_map.json --lock ./deno.lock main.ts

What fixed it was simply one of these:

chown $MY_USER deno.lock

or

chmod 666 deno.lock

Keep in mind 664 did NOT work. So something is requiring write permissions on the lock file.

@ralyodio Your error is unrelated to this issue. That “Permission denied” error is coming from the operating system, not from Deno. Your user account does not have the right privileges to execute the Chromium binary.

I had this same error and I couldn’t solve it using a user not even with sudo, but with the root user it works perfectly