Zrok stopped working (401 Unauthorized error)

I'm running Windows 10.

I use Zrok for testing purposes, I run my usual command:

zrok share public localhost:8000

It usually works, but today it gives me:

[ERROR]: unable to create share (unable to create share: [POST /share][401] shareUnauthorized)

How do I fix this?

I fixed it simply by running:

zrok disable

Then:

zrok enable <my token>

Just in case anyone encounters the same problem!

Hi @simplisticallysimple, welcome to the community and to zrok (and OpenZiti)! Congratulations, I think that's the quickest self answer ever! :smile: Glad you got it sorted.

If you find that is necessary to do again, please let us know. You certainly shouldn't need to do that. Cheers!

1 Like

I tried to disable and enable again but it does not work.
may be since I deleted envi from api.zrok.io?
What can I do next

1 Like

I was using zrok-share.service (zrok frontdoor) and I had this error.

I uninstalled (purge) zrok-share and then I removed /var/lib/private/zrok-share and /var/lib/zrok-share too. I'm not sure what exactly was the problem. I also did zrok disable, changed account token, changed environment name...

Then everything worked again.

Hi @Deme94 welcome to the community and to zrok (and OpenZiti)!

If you get this issue again, could you let us know so we can try to figure out what happened and why? Were there any logs captured you could show us? That sort of issue should not happen without a good reason.

Are you willing to share (through DM here or email) your zrok account and IP that had this issue so we can try to look through out logs?

Hi @TheLumberjack
I'm so sorry I forgot to copy the error and I cleared the log because it was repeated many times.

The error was the same from this topic (reserve command worked fine, it was the share command that failed)

zrok-share worked well the first time, but then I deleted the environment because I wanted to use an environment I had already created manually with the commands (not using the zrok-share.service). Now I know it is not necessary, zrok-share service does everything automatically.
Then, the problem happened, I changed the zrok target to the existing environment in the zrok-share.env file and it didn't work. Then I tried changing target, token, etc and nothing.

I think it only worked after I removed /var/lib/private/zrok-share because I tried uninstalling and removing other files before and it didn't work.

I am using a Raspberry Bookworm OS.

Greetings :smiley:

I have encountered this issue too.
I could share details to help investigate the issue.

here's the address:
o4h90owezixt

Hi @softdev45, welcome to the community and to zrok (and OpenZiti and BrowZer). I'll see if I can get someone to reply back with the issue. This is often due to tripping the usage limits in some way. I don't have great visibility there so I'll have to ask around and get someone better versed than me to reply.

@Deme94 I'm so sorry I lost sight of your reply! :frowning: Did you ever get this sorted?

@softdev45 ... it looks like you might have 5 shares allocated currently, and this is the limit of the number of shares you can have with a free account. If you remove one or more of the shares, you'll be able to create new ones.

I think the problem is related to an issue with the release because, I always release the tokens or shares but they get stuck. Is there a way to release a share from the command line?

There is not a method to release shares from the command line... if you terminate the zrok share process with a signal that does not allow the shutdown hook to run... then you'll have to go into the web interface and release them there. There is a button there that will allow you to do it.

If you're doing something programmatically, you could also call the "unshare" API call directly.

Hi michael, I will try it

how can I call the unshare api directly (I know that I can use curl or something like that) but how do I authenticate?

You can use a curl like this:

curl -H "X-TOKEN: <accountToken>" -XDELETE -H "Content-Type: application/zrok.v1+json" -d '{"envZId": "<ziti_identity>", "shareToken": "<shareToken>", "reserved": <reservedState>}' https://api-v1.zrok.io/api/v1/unshare

accountToken is your account token.

ziti_identity comes from the $HOME/.zrok/environment.json file (it is ziti_identity in that file).

shareToken is the share you want to release.

reservedState is a boolean value (no quotes) that must match whether or not the share is reserved or not.

You can also use:

$ curl -H "X-TOKEN: <accountToken>" https://api-v1.zrok.io/api/v1/overview

Which will give you an overview of all of the environments and shares in your account. You can retrieve ziti_identity by getting the zId value from the appropriate environment through that API call, also.

Thank you, I created a python code in order to do that. One question: if i don't send the reserved status what happends?

If the reserved status send does not match the configuration of the share, it does not get removed.