File 10 · Quick answer
Got an X login code you didn't ask for? What it means
An unrequested code from X usually means someone typed your username, email or phone number into a login or reset screen. Here's how to tell which, and what to do.
Short answer
An X code you didn't request means someone entered your account details on a login or password reset screen. A two-factor login code suggests they also have your password, so change it right away; a password reset code means they only know your username, email or phone number. Either way, never share the code with anyone, and don't click links in the message.
Key takeaways
- Never read out, forward or type the code anywhere except the screen you opened yourself.
- A two-factor login code means the password step was passed: change your password now.
- A password reset code needs no password; turn on password reset protect to make it harder.
- Anyone who messages you asking for a code you just received is running a scam.
Your phone buzzes with a six-digit code from X, and you weren't logging in. It's an unsettling message, but it's also a warning you got in time. The code itself is harmless as long as it stays with you. What matters is working out why it was sent.
Why did X send me a code I didn't request?
Someone typed your username, email address or phone number into X's login or password reset screen, and X sent the code to you, the real owner.
That someone might be an attacker with a leaked password list, a person trying to take over your account by resetting the password, or occasionally a stranger who mistyped their own number. X can't tell intentions apart. It sends the code to the contact details on the account and waits for the right person to enter it.
Read the message closely, because the type of code tells you how far the attempt got.
Which kind of code was it?
A two-factor login code means your password was entered correctly; a password reset code means it wasn't needed.
| Message says | What it means | Risk level |
|---|---|---|
| Login or verification code for signing in | Someone passed the password step | High: your password is known |
| Password reset code or link | Someone asked to reset your password | Medium: they know an identifier, not your password |
| Code for adding a phone number or email | Someone may be signing up with your number | Low, unless it repeats |
| Message asks you to reply or tap a link | Possibly not from X at all | Treat as phishing |
If you use an authenticator app or security key for two-factor authentication, you won't receive login codes by text, so an unexpected code by SMS is more likely a reset attempt or a fake message.
What should I do right now?
Don't share the code, then secure the account from the X app itself: new password, sign out of other sessions, stronger two-factor.
- Leave the message alone. Don't reply, don't tap links, don't forward it.
- Open the X app or type x.com yourself. Go to Settings and privacy > Your account > Change your password and set a new, unique password, ideally from a password manager.
- In Security and account access, open Apps and sessions and log out of any session you don't recognize. Our guide to checking connected apps and sessions on X walks through it.
- Check that two-factor authentication is on, and switch from SMS to an authenticator app or security key if you can.
- Turn on password reset protect under Security, so reset requests need your email or phone confirmed first.
If the code was a password reset and nothing else looks wrong, steps 4 and 5 are the important ones.
What if someone messages me asking for the code?
It's a scam every time; real X staff, friends and "support agents" never need a code that was sent to you.
A common trick runs like this. An attacker starts a password reset on your account, then messages you pretending to be X support, a friend or a brand partner. They say a code was "sent by mistake" or is needed "to verify your account" and ask you to pass it on. The code you'd hand over is the key to your own account.
The same trick is used on WhatsApp, Google Voice, banking apps and others. The rule doesn't change: a code sent to you is for you to type into a screen you opened yourself. Our guide to spotting impersonation and fake X support accounts covers more of these approaches.
How do I know if the attacker got in?
Check your sessions, your email for X security notices, and your recent posts and DMs for anything you didn't do.
Signs that someone logged in:
- A session or device in Apps and sessions you don't recognize.
- Emails from X about a new login, a changed email address or a changed password.
- Posts, replies, likes or DMs you didn't send.
- Your email address or phone number changed in account settings.
If any of these appear, follow our checklist for the first hour after your X account is hacked.
How can I stop the codes from coming?
You can't stop people typing your username, but you can make every attempt fail.
- Use a unique password that isn't shared with any other site. Reused passwords are the most common way the password step gets passed.
- Use an authenticator app, security key or passkey, as covered in our guide to setting up 2FA and passkeys on X.
- Turn on password reset protect.
- Secure the email account linked to X, since it can reset your X password.
Then run the 5-minute security check to see what else is still open.
Questions
Can someone hack my X account with just the code?
Not on its own, but the code is the last piece they need if they already have your password or are resetting it. That's why scammers ask for it. Keeping it to yourself blocks the attempt.
I got a code but my password is fine. Should I still change it?
If it was a two-factor login code, yes. Two-factor codes are sent only after a correct password. If it was a password reset code, changing the password isn't strictly needed, but turning on password reset protect is worth doing.
The text says it's from X but has a link. Is it real?
Treat any code message with a link, an urgent warning or a request to reply as suspicious. Open the X app or type x.com yourself and check Security settings there instead.
Why do I keep getting codes every few hours?
Someone is repeatedly trying your account, often with a list of leaked passwords. Change your password to a unique one, use an authenticator app or security key, and turn on password reset protect. The attempts usually stop once they fail.
Sources
- X Help Center: How to use two-factor authentication
- X Help Center: Help with a compromised account
- FTC: How to recognize and avoid phishing scams
TweetAttacks is independent and not affiliated with X Corp. Settings names can change when X updates its apps; if a menu has moved, search its name in X's settings.