"vagrant up" got Error: The requested URL returned error: 401

Steps to reproduce:

  1. init a “public box”
$ vagrant init bento/rockylinux-10
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
  1. Run vagrant up
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/rockylinux-10' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
The box 'bento/rockylinux-10' could not be found or could not be accessed in the remote catalog.
If this is a private box on the HashiCorp Vagrant Public Registry, please verify
you're logged in via `vagrant cloud auth login`. Also, please double-check the name.
The expanded URL and error message are shown below:

URL: ["https://vagrantcloud.com/bento/rockylinux-10"]
Error: The requested URL returned error: 401

Howerver, this url “https://vagrantcloud.com/bento/rockylinux-10” can be accessed via web browser without problem.

Version Information

  • Vagrant: 2.4.8
  • VirtualBox: 7.1.12

Hi @eliu,

This is happening because an expired auth token is set in your env, you can unset the VAGRANT_CLOUD_TOKEN env variable and it should work post that.

Cheers!

Hi @unfade ,

I don’t have any env variable named `VAGRANT_CLOUD_TOKEN`

$ echo $VAGRANT_CLOUD_TOKEN

Hi @eliu ,
Could you check the documentation at Usage and Behavior Post Migration to HCP | Vagrant | HashiCorp Developer for refreshing the token ? Ideally it should be that token unless you have HCP specific tokens set.

Cheers!

Thanks! That solved my problem. One thing left on me is a little bit confused why it requires me to login when i just want to pull a public vagrant box resource~

Ideally, it should not, but if there is a cloud token or hcp auth set, then it passes the same, which can cause a failure if the token is expired.