Hello unai guedes jimenez,
Happy to help you get multiplayer working — before I point you at the fix, a couple of quick things would help, since the cause is usually different depending on the account setup:
- Are you playing on PC or an Xbox console, and is it Java or Bedrock?
- Is this account a child account, or is it (or was it ever) part of a Microsoft Family group?
- What's the exact message you see when multiplayer fails?
In the meantime, the setting that actually matters lives here:
- Go to Privacy & online safety > Xbox privacy > View details & customize > Communication & multiplayer
- Set "You can join multiplayer games" to Allow (and "play with people outside Xbox" / cross-network too if relevant)
- Then fully sign out of Minecraft and restart it — the change tends to need a fresh sign-in before it sticks, though it's usually minutes, not hours
Note that if the account is (or used to be) in a Family group, the organizer has to make that change, and sometimes the restriction lingers a bit even after the account's removed.