How can I generate a new admin secret?

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

When I set up the project a secret got added to the server.js file, and I moved that secret to my .env file. However during some migration of files on my system I no longer have my .env file and Strapi is now giving me an error trying to log into the admin. How can I create a new secret string without reinstalling the whole project from scratch?

If you are on a unix system (mac or Linux) you can create one by running this in the terminal

openssl rand -base64 32
If you are on windows you can use git bash to execute the same same command.

This will generate a new random string

I would recommend 64 instead of 32 but yes.