Encryption key is invalid - Not able to reset password or create new user after migration to new server

Not able to create a new user or reset the password of existing user.

Error is as mentioned.

Encryption key is invalid, Please check site_config.json

When, replaced the encryption key with the Old server site_config.json. The the instance doesn’t work at all.

replacing the old encryption should work, can you share the full error traceback?

would you guide me, where to check for error traceback

1 Like

Please find the trackback logs

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 56, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 21, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 52, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 913, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 764, in reset_password
user.reset_password(send_email=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 209, in reset_password
self.password_reset_mail(link)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 228, in password_reset_mail
“templates/emails/password_reset.html”, {“link”: link}, now=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 283, in send_login_mail
delayed=(not now) if now!=None else self.flags.delay_emails, retry=3)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 424, in sendmail
inline_images=inline_images)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 62, in send
email_account = get_outgoing_email_account(True, append_to=reference_doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 54, in get_outgoing_email_account
email_account = get_default_outgoing_email_account(raise_exception_not_set=raise_exception_not_set)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/smtp.py”, line 87, in get_default_outgoing_email_account
email_account.password = email_account.get_password(raise_exception=False)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 664, in get_password
return get_decrypted_password(self.doctype, self.name, fieldname, raise_exception=raise_exception)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/password.py”, line 16, in get_decrypted_password
return decrypt(auth[0][0])
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/password.py”, line 101, in decrypt
cipher_suite = Fernet(encode(get_encryption_key()))
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/cryptography/fernet.py”, line 34, in init
key = base64.urlsafe_b64decode(key)
File “/usr/lib/python2.7/base64.py”, line 112, in urlsafe_b64decode
return b64decode(s, ‘-_’)
File “/usr/lib/python2.7/base64.py”, line 76, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding

@shreyasdk,

remove the old encryption key the system will generate the new encryption key in site_config.json automatically

was able to fix this issue, after configuring the email account. We may close this thread.

Thank you for your help in solving this.

How can i fix this issue using vm ?

For all password reset and related activities, ERPnext uses smtp configuration to send the notification email to user. If this is not configured, ERPnext will be showing encryption key error on site_config.json.

Once you configure the email account you will be able to resolve the issue.

How to remove?

Hello,

If this is about the encryption key all you have to do is go to your frappe/sites/your_site folder, open site_config.json and remove "encryption_key" : "the_encryption_key" from the file.

Save the file and restart your bench.

Regards,

Hera