v2rayA/v2rayA · error
wrong username or password
Error message
wrong username or password
What it means
Login validates credentials with IsValidAccount(username, password); if the check fails it returns the fixed message 'wrong username or password'. This is a deliberate generic error so it does not reveal whether the username or the password was wrong.
Source
Thrown at service/server/service/account.go:14
package service
import (
"fmt"
"time"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/db/configure"
"github.com/v2rayA/v2rayA/pkg/server/jwt"
)
func Login(username, password string) (token string, err error) {
if !IsValidAccount(username, password) {
return "", fmt.Errorf("wrong username or password")
}
dur := 30 * 24 * time.Hour
return jwt.MakeJWT(map[string]string{
"uname": username,
}, &dur)
}
func IsValidAccount(username, password string) bool {
pwd, err := configure.GetPasswordOfAccount(username)
if err != nil {
return false
}
return common.CheckPassword(password, pwd)
}
func Register(username, password string) (token string, err error) {
if configure.ExistsAccount(username) {
return "", fmt.Errorf("username exists")View on GitHub (pinned to 71e5442fc5)
Solutions
- Re-enter credentials carefully, checking case and whitespace
- If the account was never created, register first (PostAccount) before logging in
- Confirm v2rayA is pointed at the config directory that actually holds the account
- If the password is lost, delete/recreate the account in the config db
Defensive patterns
Strategy: try-catch
Validate before calling
if username == "" || password == "" {
return errors.New("username and password are required")
} Try / catch
token, err := service.Login(user, pass)
if err != nil && err.Error() == "wrong username or password" {
// show generic auth-failure message, do not leak which field failed
return err
} Prevention
- Register the account before attempting login
- Verify the correct --v2raya-confdir so the right account db is used
- Trim whitespace and respect case in usernames
- Use a password manager to avoid typos
When it happens
Trigger: POSTing to the login endpoint with a username that has no account in configure's account store, or with a password whose hashed value does not match the stored CryptoPwd hash.
Common situations: Typo in either field; account registered in a different config directory (wrong --v2raya-confdir so the db has no such user); password changed elsewhere; case/whitespace differences in username.
Related errors
AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05).
Data as JSON: /api/errors/e95763e34cea9dcb.
Report an issue: GitHub.