login error 401 #21334

Closed
opened 2026-02-21 20:12:01 -05:00 by yindo · 3 comments
Owner

Originally created by @kaxipig on GitHub (Dec 29, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

I downloaded the GitHub source code for Dify version 1.11.1 and followed the instructions to start the API/web applications. The middleware (pg15/17) and Redis service are accessible locally, and table structure initialization is normal. However, I encounter an error when registering the first account, although the account information can be written to the accounts table. I consistently get a 401 error message indicating an incorrect login username or password.

API configuration: CONSOLE_CORS_ALLOW_ORIGINS=*

WEB_API_CORS_ALLOW_ORIGINS=*

Could you please provide a complete single-machine source code startup process, not Docker?

✔️ Expected Behavior

Could you please provide a complete single-machine source code startup process, not Docker?

Actual Behavior

401 error message indicating an incorrect login username or password.

Originally created by @kaxipig on GitHub (Dec 29, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.1 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce I downloaded the GitHub source code for Dify version 1.11.1 and followed the instructions to start the API/web applications. The middleware (pg15/17) and Redis service are accessible locally, and table structure initialization is normal. However, I encounter an error when registering the first account, although the account information can be written to the `accounts` table. I consistently get a 401 error message indicating an incorrect login username or password. API configuration: `CONSOLE_CORS_ALLOW_ORIGINS=*` `WEB_API_CORS_ALLOW_ORIGINS=*` Could you please provide a complete single-machine source code startup process, not Docker? ### ✔️ Expected Behavior Could you please provide a complete single-machine source code startup process, not Docker? ### ❌ Actual Behavior 401 error message indicating an incorrect login username or password.
yindo added the 🐞 bug label 2026-02-21 20:12:01 -05:00
yindo closed this issue 2026-02-21 20:12:01 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 29, 2025):

Hi @kaxipig! I'm Dosu and I’m helping the dify team.

A persistent 401 error during registration or login in self-hosted Dify (source, not Docker) is almost always caused by missing or misconfigured environment variables, incomplete setup, or browser cookie issues. Here’s a step-by-step guide to get a working single-machine source setup and avoid 401 errors:

1. Prepare prerequisites:

  • Python 3.10+ (for API/worker), Node.js 18+ (for frontend), PostgreSQL (pg15/17), and Redis running locally.

2. Clone the repo and install dependencies:

  • Backend:
    cd api
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    
  • Frontend:
    cd web
    npm install
    

3. Set up your .env files:
In api/.env, set at least:

SECRET_KEY=your_strong_secret_key
WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,*
CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,*
CONSOLE_API_URL=http://localhost:5001
CONSOLE_WEB_URL=http://localhost:3000
SERVICE_API_URL=http://localhost:5001
APP_WEB_URL=http://localhost:3000
ALLOW_REGISTER=true
ALLOW_CREATE_WORKSPACE=true
ENABLE_EMAIL_PASSWORD_LOGIN=true

Generate a strong SECRET_KEY (e.g., openssl rand -base64 42).
Do not set INIT_PASSWORD unless you want an extra initialization step (usually not needed for local/source installs)
Reference

4. Initialize the database:

  • Make sure your PostgreSQL and Redis are running and accessible.
  • Run migrations if needed (see api/README.md).

5. Start the backend services:

  • API:
    cd api
    source venv/bin/activate
    python main.py
    
  • Worker (in another terminal):
    cd api
    source venv/bin/activate
    celery -A celery_worker.celery worker --loglevel=info
    

6. Start the frontend:

cd web
npm run dev

(or npm run build && npm run start for production)

7. Complete the setup:

  • Visit http://localhost:3000 in your browser.
  • If prompted for setup, fill in the admin account info. This creates the required DifySetup record in the database.
  • If you see a login/register screen but get 401 errors, double-check your .env values and restart all services after any change.

8. Troubleshooting 401 errors:

  • Make sure all services are restarted after changing .env.
  • Explicitly include http://localhost:3000 in your CORS origins.
  • Use a strong SECRET_KEY and confirm it is set before starting the API.
  • If you set INIT_PASSWORD, you must validate it before setup; otherwise, remove it.
  • Check browser cookie settings: Chrome may block cookies on localhost due to SameSite policies. For local dev, you may need to launch Chrome with --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure.
  • If you still get 401s, check backend logs for errors, verify database and Redis connectivity, and ensure no port/protocol mismatches between frontend and backend URLs.

If you follow these steps and still see 401 errors, check for any error messages in the backend logs and confirm that the DifySetup record exists in your database.
More details and common pitfalls
Source code references for setup and authentication

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 29, 2025): <!-- Greeting --> Hi @kaxipig! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> A persistent 401 error during registration or login in self-hosted Dify (source, not Docker) is almost always caused by missing or misconfigured environment variables, incomplete setup, or browser cookie issues. Here’s a step-by-step guide to get a working single-machine source setup and avoid 401 errors: **1. Prepare prerequisites:** - Python 3.10+ (for API/worker), Node.js 18+ (for frontend), PostgreSQL (pg15/17), and Redis running locally. **2. Clone the repo and install dependencies:** - Backend: ``` cd api python3 -m venv venv source venv/bin/activate pip install -r requirements.txt ``` - Frontend: ``` cd web npm install ``` **3. Set up your `.env` files:** In `api/.env`, set at least: ``` SECRET_KEY=your_strong_secret_key WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,* CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,* CONSOLE_API_URL=http://localhost:5001 CONSOLE_WEB_URL=http://localhost:3000 SERVICE_API_URL=http://localhost:5001 APP_WEB_URL=http://localhost:3000 ALLOW_REGISTER=true ALLOW_CREATE_WORKSPACE=true ENABLE_EMAIL_PASSWORD_LOGIN=true ``` Generate a strong `SECRET_KEY` (e.g., `openssl rand -base64 42`). **Do not** set `INIT_PASSWORD` unless you want an extra initialization step (usually not needed for local/source installs) [Reference](https://github.com/langgenius/dify/discussions/29261) **4. Initialize the database:** - Make sure your PostgreSQL and Redis are running and accessible. - Run migrations if needed (see `api/README.md`). **5. Start the backend services:** - API: ``` cd api source venv/bin/activate python main.py ``` - Worker (in another terminal): ``` cd api source venv/bin/activate celery -A celery_worker.celery worker --loglevel=info ``` **6. Start the frontend:** ``` cd web npm run dev ``` (or `npm run build && npm run start` for production) **7. Complete the setup:** - Visit `http://localhost:3000` in your browser. - If prompted for setup, fill in the admin account info. This creates the required `DifySetup` record in the database. - If you see a login/register screen but get 401 errors, double-check your `.env` values and restart all services after any change. **8. Troubleshooting 401 errors:** - Make sure all services are restarted after changing `.env`. - Explicitly include `http://localhost:3000` in your CORS origins. - Use a strong `SECRET_KEY` and confirm it is set before starting the API. - If you set `INIT_PASSWORD`, you must validate it before setup; otherwise, remove it. - Check browser cookie settings: Chrome may block cookies on localhost due to SameSite policies. For local dev, you may need to launch Chrome with `--disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure`. - If you still get 401s, check backend logs for errors, verify database and Redis connectivity, and ensure no port/protocol mismatches between frontend and backend URLs. If you follow these steps and still see 401 errors, check for any error messages in the backend logs and confirm that the `DifySetup` record exists in your database. [More details and common pitfalls](https://github.com/langgenius/dify/discussions/29261) [Source code references for setup and authentication](https://github.com/langgenius/dify/blob/09be869f589b81921ddf72721ce8fbb2c8dfcc6c/api/controllers/console/setup.py#L19-L105) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/68d3d059-0927-4ac2-b7d1-d9bf34bddb06?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=A%20persistent%20401%20error%20during%20registration%20or%20login%20in%20self-hosted%20Dify%20%28source%2C%20not%20Docker%29%20is%20almost%20always%20caused%20by%20missing%20or%20misconfigured%20environment%20variables%2C%20incomplete%20setup%2C%20or%20browser%20cookie%20issues.%20Here%E2%80%99s%20a%20step-by-step%20guide%20to%20get%20a%20working%20single-machine%20source%20setup%20and%20avoid%20401%20errors%3A%0A%0A%2A%2A1.%20Prepare%20prerequisites%3A%2A%2A%20%20%0A-%20Python%203.10%2B%20%28for%20API/worker%29%2C%20Node.js%2018%2B%20%28for%20frontend%29%2C%20PostgreSQL%20%28pg15/17%29%2C%20and%20Redis%20running%20locally.%0A%0A%2A%2A2.%20Clone%20the%20repo%20and%20install%20dependencies%3A%2A%2A%20%20%0A-%20Backend%3A%20%20%0A%20%20%60%60%60%0A%20%20cd%20api%0A%20%20python3%20-m%20venv%20venv%0A%20%20source%20venv/bin/activate%0A%20%20pip%20install%20-r%20requirements.txt%0A%20%20%60%60%60%0A-%20Frontend%3A%20%20%0A%20%20%60%60%60%0A%20%20cd%20web%0A%20%20npm%20install%0A%20%20%60%60%60%0A%0A%2A%2A3.%20Set%20up%20your%20%60.env%60%20files%3A%2A%2A%20%20%0AIn%20%60api/.env%60%2C%20set%20at%20least%3A%0A%60%60%60%0ASECRET_KEY%3Dyour_strong_secret_key%0AWEB_API_CORS_ALLOW_ORIGINS%3Dhttp%3A//localhost%3A3000%2C%2A%0ACONSOLE_CORS_ALLOW_ORIGINS%3Dhttp%3A//localhost%3A3000%2C%2A%0ACONSOLE_API_URL%3Dhttp%3A//localhost%3A5001%0ACONSOLE_WEB_URL%3Dhttp%3A//localhost%3A3000%0ASERVICE_API_URL%3Dhttp%3A//localhost%3A5001%0AAPP_WEB_URL%3Dhttp%3A//localhost%3A3000%0AALLOW_REGISTER%3Dtrue%0AALLOW_CREATE_WORKSPACE%3Dtrue%0AENABLE_EMAIL_PASSWORD_LOGIN%3Dtrue%0A%60%60%60%0AGenerate%20a%20strong%20%60SECRET_KEY%60%20%28e.g.%2C%20%60openssl%20rand%20-base64%2042%60%29.%20%20%0A%2A%2ADo%20not%2A%2A%20set%20%60INIT_PASSWORD%60%20unless%20you%20want%20an%20extra%20initialization%20step%20%28usually%20not%20needed%20for%20local/source%20installs%29%20%20%0A%5BReference%5D%28https%3A//github.com/langgenius/dify/discussions/29261%29%0A%0A%2A%2A4.%20Initialize%20the%20database%3A%2A%2A%20%20%0A-%20Make%20sure%20your%20PostgreSQL%20and%20Redis%20are%20running%20and%20accessible.%0A-%20Run%20migrations%20if%20needed%20%28see%20%60api/README.md%60%29.%0A%0A%2A%2A5.%20Start%20the%20backend%20services%3A%2A%2A%20%20%0A-%20API%3A%20%20%0A%20%20%60%60%60%0A%20%20cd%20api%0A%20%20source%20venv/bin/activate%0A%20%20python%20main.py%0A%20%20%60%60%60%0A-%20Worker%20%28in%20another%20terminal%29%3A%20%20%0A%20%20%60%60%60%0A%20%20cd%20api%0A%20%20source%20venv/bin/activate%0A%20%20celery%20-A%20celery_worker.celery%20worker%20--loglevel%3Dinfo%0A%20%20%60%60%60%0A%0A%2A%2A6.%20Start%20the%20frontend%3A%2A%2A%20%20%0A%20%20%60%60%60%0A%20%20cd%20web%0A%20%20npm%20run%20dev%0A%20%20%60%60%60%0A%20%20%28or%20%60npm%20run%20build%20%26%26%20npm%20run%20start%60%20for%20production%29%0A%0A%2A%2A7.%20Complete%20the%20setup%3A%2A%2A%20%20%0A-%20Visit%20%60http%3A//localhost%3A3000%60%20in%20your%20browser.%20%20%0A-%20If%20prompted%20for%20setup%2C%20fill%20in%20the%20admin%20account%20info.%20This%20creates%20the%20required%20%60DifySetup%60%20record%20in%20the%20database.%20%20%0A-%20If%20you%20see%20a%20login/register%20screen%20but%20get%20401%20errors%2C%20double-check%20your%20%60.env%60%20values%20and%20restart%20all%20services%20after%20any%20change.%0A%0A%2A%2A8.%20Troubleshooting%20401%20errors%3A%2A%2A%20%20%0A-%20Make%20sure%20all%20services%20are%20restarted%20after%20changing%20%60.env%60.%0A-%20Explicitly%20include%20%60http%3A//localhost%3A3000%60%20in%20your%20CORS%20origins.%0A-%20Use%20a%20strong%20%60SECRET_KEY%60%20and%20confirm%20it%20is%20set%20before%20starting%20the%20API.%0A-%20If%20you%20set%20%60INIT_PASSWORD%60%2C%20you%20must%20validate%20it%20before%20setup%3B%20otherwise%2C%20remove%20it.%0A-%20Check%20browser%20cookie%20settings%3A%20Chrome%20may%20block%20cookies%20on%20localhost%20due%20to%20SameSite%20policies.%20For%20local%20dev%2C%20you%20may%20need%20to%20launch%20Chrome%20with%20%60--disable-features%3DSameSiteByDefaultCookies%2CCookiesWithoutSameSiteMustBeSecure%60.%0A-%20If%20you%20still%20get%20401s%2C%20check%20backend%20logs%20for%20errors%2C%20verify%20database%20and%20Redis%20connectivity%2C%20and%20ensure%20no%20port/protocol%20mismatches%20between%20frontend%20and%20backend%20URLs.%0A%0AIf%20you%20follow%20these%20steps%20and%20still%20see%20401%20errors%2C%20check%20for%20any%20error%20messages%20in%20the%20backend%20logs%20and%20confirm%20that%20the%20%60DifySetup%60%20record%20exists%20in%20your%20database.%20%20%0A%5BMore%20details%20and%20common%20pitfalls%5D%28https%3A//github.com/langgenius/dify/discussions/29261%29%20%20%0A%5BSource%20code%20references%20for%20setup%20and%20authentication%5D%28https%3A//github.com/langgenius/dify/blob/09be869f589b81921ddf72721ce8fbb2c8dfcc6c/api/controllers/console/setup.py%23L19-L105%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30309)
Author
Owner

@kaxipig commented on GitHub (Dec 29, 2025):

@dosu

Thanks @dosu. I only started Redis, pg15, API (using UV Flask), worker, and web, and the env configuration in API only shows:

SECRET_KEY=version (openssl 3.0.4)secret_key
WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,*
CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,*
CONSOLE_API_URL=http://localhost:5001
CONSOLE_WEB_URL=http://localhost:3000
SERVICE_API_URL=http://localhost:5001
APP_WEB_URL=http://localhost:3000
ALLOW_REGISTER=true
ALLOW_CREATE_WORKSPACE=true
ENABLE_EMAIL_PASSWORD_LOGIN=true; I reinitialized the Dify library and restarted API, worker, and web. The startup process shows normal results, but registration still fails with a 401 Invalid encrypted_data error.

celery@hostname ready

running on http://ip:5001

http://ip:3000 also works.

Thank you for your guidance.

@kaxipig commented on GitHub (Dec 29, 2025): @dosu Thanks @dosu. I only started Redis, pg15, API (using UV Flask), worker, and web, and the env configuration in API only shows: SECRET_KEY=version (openssl 3.0.4)secret_key WEB_API_CORS_ALLOW_ORIGINS=http://localhost:3000,* CONSOLE_CORS_ALLOW_ORIGINS=http://localhost:3000,* CONSOLE_API_URL=http://localhost:5001 CONSOLE_WEB_URL=http://localhost:3000 SERVICE_API_URL=http://localhost:5001 APP_WEB_URL=http://localhost:3000 ALLOW_REGISTER=true ALLOW_CREATE_WORKSPACE=true ENABLE_EMAIL_PASSWORD_LOGIN=true; I reinitialized the Dify library and restarted API, worker, and web. The startup process shows normal results, but registration still fails with a 401 Invalid encrypted_data error. celery@hostname ready running on http://ip:5001 http://ip:3000 also works. Thank you for your guidance.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 29, 2025):

The "401 Invalid encrypted_data" error means the backend failed to base64-decode a sensitive field (like the password) sent from the frontend during registration. This is not caused by your SECRET_KEY or environment variables, but by the frontend sending data that isn't properly base64-encoded, or a version mismatch between frontend and backend code.

Here's how to troubleshoot:

  1. Make sure your frontend and backend are running the exact same Dify version (1.11.1). If you updated one but not the other, encoding/decoding logic may be incompatible.
  2. Open your browser's developer tools, go to the Network tab, and inspect the registration request payload. The password field should look like a base64 string (e.g., cGFzc3dvcmQxMjM= for "password123"). If it's plain text, the frontend isn't encoding it.
  3. If you see plain text, do a clean install of frontend dependencies (rm -rf node_modules && npm install) and restart the frontend.
  4. Clear your browser cache and cookies, then try again.
  5. Make sure there are no browser extensions, proxies, or firewalls modifying requests.

If you still get the error, check the backend logs for more details at the time of registration. This will help pinpoint if the payload is malformed or if there's another decoding issue.

For reference, this error is triggered by the backend's base64 decoder, not by SECRET_KEY or token logic. SECRET_KEY issues would cause "Invalid token signature" errors instead, not "Invalid encrypted_data" (source).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 29, 2025): <!-- Answer --> The "401 Invalid encrypted_data" error means the backend failed to base64-decode a sensitive field (like the password) sent from the frontend during registration. This is not caused by your SECRET_KEY or environment variables, but by the frontend sending data that isn't properly base64-encoded, or a version mismatch between frontend and backend code. Here's how to troubleshoot: 1. Make sure your frontend and backend are running the exact same Dify version (1.11.1). If you updated one but not the other, encoding/decoding logic may be incompatible. 2. Open your browser's developer tools, go to the Network tab, and inspect the registration request payload. The password field should look like a base64 string (e.g., `cGFzc3dvcmQxMjM=` for "password123"). If it's plain text, the frontend isn't encoding it. 3. If you see plain text, do a clean install of frontend dependencies (`rm -rf node_modules && npm install`) and restart the frontend. 4. Clear your browser cache and cookies, then try again. 5. Make sure there are no browser extensions, proxies, or firewalls modifying requests. If you still get the error, check the backend logs for more details at the time of registration. This will help pinpoint if the payload is malformed or if there's another decoding issue. For reference, this error is triggered by the backend's base64 decoder, not by SECRET_KEY or token logic. SECRET_KEY issues would cause "Invalid token signature" errors instead, not "Invalid encrypted_data" ([source](https://github.com/langgenius/dify/blob/2c919efa69686ce4d6f6d677da067a597597bfc6/api/libs/encryption.py#L17-L67)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/72492a41-dc22-46c1-b730-6b729f36c97c?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20%22401%20Invalid%20encrypted_data%22%20error%20means%20the%20backend%20failed%20to%20base64-decode%20a%20sensitive%20field%20%28like%20the%20password%29%20sent%20from%20the%20frontend%20during%20registration.%20This%20is%20not%20caused%20by%20your%20SECRET_KEY%20or%20environment%20variables%2C%20but%20by%20the%20frontend%20sending%20data%20that%20isn%27t%20properly%20base64-encoded%2C%20or%20a%20version%20mismatch%20between%20frontend%20and%20backend%20code.%0A%0AHere%27s%20how%20to%20troubleshoot%3A%0A%0A1.%20Make%20sure%20your%20frontend%20and%20backend%20are%20running%20the%20exact%20same%20Dify%20version%20%281.11.1%29.%20If%20you%20updated%20one%20but%20not%20the%20other%2C%20encoding/decoding%20logic%20may%20be%20incompatible.%0A2.%20Open%20your%20browser%27s%20developer%20tools%2C%20go%20to%20the%20Network%20tab%2C%20and%20inspect%20the%20registration%20request%20payload.%20The%20password%20field%20should%20look%20like%20a%20base64%20string%20%28e.g.%2C%20%60cGFzc3dvcmQxMjM%3D%60%20for%20%22password123%22%29.%20If%20it%27s%20plain%20text%2C%20the%20frontend%20isn%27t%20encoding%20it.%0A3.%20If%20you%20see%20plain%20text%2C%20do%20a%20clean%20install%20of%20frontend%20dependencies%20%28%60rm%20-rf%20node_modules%20%26%26%20npm%20install%60%29%20and%20restart%20the%20frontend.%0A4.%20Clear%20your%20browser%20cache%20and%20cookies%2C%20then%20try%20again.%0A5.%20Make%20sure%20there%20are%20no%20browser%20extensions%2C%20proxies%2C%20or%20firewalls%20modifying%20requests.%0A%0AIf%20you%20still%20get%20the%20error%2C%20check%20the%20backend%20logs%20for%20more%20details%20at%20the%20time%20of%20registration.%20This%20will%20help%20pinpoint%20if%20the%20payload%20is%20malformed%20or%20if%20there%27s%20another%20decoding%20issue.%0A%0AFor%20reference%2C%20this%20error%20is%20triggered%20by%20the%20backend%27s%20base64%20decoder%2C%20not%20by%20SECRET_KEY%20or%20token%20logic.%20SECRET_KEY%20issues%20would%20cause%20%22Invalid%20token%20signature%22%20errors%20instead%2C%20not%20%22Invalid%20encrypted_data%22%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/2c919efa69686ce4d6f6d677da067a597597bfc6/api/libs/encryption.py%23L17-L67%29%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30309)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21334