Skip to content
Back

Persistent 401 Unauthorized on all authenticated requests from localhost

  • 0
  • React Native
  • Web
  • Auth
Ислам
2 Jul, 2025, 15:18

Hello, I'm facing a critical 401 Unauthorized error on my admin panel app and have exhausted all debugging options.

The Problem:

When my React app on localhost makes any request that requires an authenticated session (like account.get() or databases.createDocument()), it fails with a 401 Unauthorized error.

This happens even after a successful account.createEmailSession() call.

What I have verified (my setup is correct):

My Project ID (6863d2f000114af88d7f) and Endpoint (https://fra.cloud.appwrite.io/v1) are 100% correct in my SDK initialization.

I have a Web App platform with the Hostname correctly set to localhost. I have deleted and re-created it.

For databases.createDocument, the Users role has full Create, Read, Update, Delete permissions on the target collection. I have verified this with screenshots.

I have tried multiple browsers, Incognito Mode, and performed Hard Reload + Empty Cache.

The project was created from scratch using Vite.

The platform seems to not recognize my valid user session, always returning 401. This feels like a platform-level anomaly specific to my project. Can you please investigate? Thank you.

TL;DR
Developers are experiencing 401 Unauthorized errors on authenticated API requests from localhost despite correct setup and permissions. The issue arises even after successful account.createEmailSession() call. Solution: The correct method is `createEmailPasswordSession`.
Axistro
2 Jul, 2025, 15:20

Is the email session is about creating user session with email and password?

Axistro
2 Jul, 2025, 15:23

Are you giving an ai genarated text?

Axistro
2 Jul, 2025, 15:24

Btw If yes Then it is createEmailPasswordSession

Ислам
2 Jul, 2025, 15:25

Yes, that's correct. My goal is to use account.createEmailSession(email, password) to log in my admin user.

However, any request to an account endpoint (like createEmailSession or get) from my app running on localhost is failing with a 401 Unauthorized error, even though my Project ID is correct and localhost is registered as a platform hostname.

Ислам
2 Jul, 2025, 15:26

Sorry(

Axistro
2 Jul, 2025, 15:26

This method does not exist afaik.

Axistro
2 Jul, 2025, 15:26

Use this

Axistro
2 Jul, 2025, 15:27

Just say what you have in mind and keep it short 😅.

Ислам
2 Jul, 2025, 15:32

My admin app on localhost gets a 401 Unauthorized error for any authenticated API request (like account.get() or databases.createDocument).

I have already verified 100% that my Project ID, Endpoint, localhost Platform, and all Permissions for the Users role are correct. The problem still happens in a brand new project and in different browsers.

It feels like a platform-level bug for my project. Project ID: 6863d2f000114af88d7f.

Axistro
2 Jul, 2025, 15:37

Most probably session is not created. You are using createEmailSession but the correct method is createEmailPasswordSession Try this if it helps

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more