Sub topic 7
Logging in through your My Domain URL
This chapter assumes you have completed sign-up, verified your email, set a password and registered a multi-factor authentication (MFA) method. It also assumes you know what a URL's host name is. The terminal commands near the end use the Salesforce CLI (sf), which a later chapter covers in full.
What My Domain is
My Domain is a custom sub-domain that Salesforce assigns to your org. Every request to your org goes to this host name instead of a shared server name.
A Developer Edition org usually gets a domain like this:
https://acme-dev-ed.develop.my.salesforce.comThe parts of the host name are:
| Part | Example | Meaning |
|---|---|---|
| Your prefix | `acme-dev-ed` | A name chosen during sign-up, often with a `-dev-ed` suffix |
| Org-type segment | `develop` | Marks the org as a Developer Edition org |
| Base domain | `my.salesforce.com` | The shared Salesforce domain for My Domain URLs |
The exact format can change between releases, so copy your URL from your own org instead of building it by hand. Salesforce also serves some Setup and Lightning pages from related hosts such as *.lightning.force.com and *.my.salesforce-setup.com. Seeing a different host after login is normal.
My Domain is required in all orgs. You don't enable it in a new Developer Edition org. It is already deployed, and your sign-up confirmation email contains the link.
Why My Domain matters
- It gives your org a stable, unique login address.
- Lightning Experience, Experience Cloud sites and many integrations depend on it.
- It lets Salesforce tie a login page to one org, so a single-sign-on or branding setting applies only to that org.
- Tools that build URLs, such as the CLI and API clients, use it as the instance URL.
Three ways to reach the login page
You can sign in at any of these addresses:
- Your My Domain URL. This is the best option because it goes straight to your org.
https://login.salesforce.com. The generic production login page. A Developer Edition org counts as a production-type org, so it works here.https://test.salesforce.com. This is for sandboxes. Don't use it for a Developer Edition org.
On the generic page you enter your username and password, and Salesforce works out which org you belong to. Salesforce can then redirect you to your My Domain URL.
Signing in step by step
- Open your My Domain URL in a browser. Bookmark it.
- In Username, enter the full username you chose at sign-up. It looks like an email address, such as
[email protected]. It does not have to be a mailbox that exists, and it may differ from your contact email. - Enter your password.
- Select Log In.
- Complete the MFA prompt with the method you registered, such as an authenticator app code or a security key tap.
- Salesforce opens the Home page in Lightning Experience.
Select Remember me to have the login page fill in your username next time. It stores only the username, never the password. Don't use it on a shared computer.
The role of MFA at login
Salesforce requires MFA for direct logins to the user interface. The password check happens first. If it passes, Salesforce asks for the second factor. Two details are worth knowing:
- A one-time code from an authenticator app is valid for a short window, about 30 seconds. If the code is rejected, wait for the next one and check that your phone's clock is correct.
- If you lose your registered method, you can't just reset the password to get around MFA. Registering a second method in advance, such as a security key or a different authenticator, avoids that situation.
The CLI sign-in later in this tutorial also goes through this same MFA step, because it uses the browser login.
Finding your own My Domain URL
If you lost the sign-up email, you can still find the URL. There are three ways.
From Setup. After you log in, select the gear icon, then Setup. In the Quick Find box type My Domain, then open My Domain. The page shows your current My Domain name and the full URL.
From the browser address bar. The host name in the address bar while you are logged in is your My Domain host. Ignore the lightning.force.com or salesforce-setup.com variants. They are related hosts.
From Apex. Run this as anonymous Apex, for example in the Developer Console (Debug, then Open Execute Anonymous Window):
System.debug('My Domain URL: ' + URL.getOrgDomainUrl().toExternalForm());
System.debug('Username: ' + UserInfo.getUserName());Select Open Log and filter for USER_DEBUG. The first line prints the My Domain URL and the second prints the username that is logged in.
Using the CLI to open the org
Once the CLI has an authorization for your org, you don't need to type a password to enter the org. You can print the login URL or open it directly:
sf org open --target-org my-dev-org
sf org open --target-org my-dev-org --url-onlyThe first command opens your default browser at a session-ready URL. The second prints the URL without opening a browser, which is useful on a machine without a browser or inside a script.
You can also see which instance URL the CLI recorded for the alias:
sf org display --target-org my-dev-orgThe output includes the username, the org ID and the Instance Url, which should match your My Domain URL.
Security settings that affect login
You can inspect these in Setup, though a fresh Developer Edition org already has sensible defaults.
| Setting | Where to find it | What it controls |
|---|---|---|
| Login history | Setup, then **Login History** | Time, IP address, application and status of each login attempt |
| Session settings | Setup, then **Session Settings** | How long an idle session lasts before you must sign in again |
| Password policies | Setup, then **Password Policies** | Expiry, complexity and the lockout rule |
| Login IP ranges | The user's **Profile** | Which IP addresses may log in with that profile |
| Login hours | The user's **Profile** | When the profile may log in |
Login History is the first place to look when something fails. A failed attempt appears with a status such as "Invalid Password", which tells you whether the problem is the username, the password or a policy.
By default, repeated wrong passwords lock the user for a period. The default is commonly 10 attempts and a 15-minute lock, but the policy is configurable. If you are locked out, wait for the lock to expire, or reset the password from the login page.
Resetting a forgotten password
- On the login page, select Forgot Your Password?.
- Enter your username and select Continue.
- Open the email Salesforce sends to the address on your user record.
- Follow the link and set a new password that meets the policy.
- Log in with the new password and complete MFA.
The reset email goes to the email on your user record, not to the username. If that email is wrong or you can't open it, you can't self-serve the reset. In a Developer Edition org where you are the only administrator, you may need to sign up for a fresh org.
Common login problems
- "Your login attempt has failed." Check that you typed the username, not the email. Check the keyboard layout and caps lock too.
- "We can't find that domain" or a DNS error. The host name is mistyped. Copy the URL from the confirmation email or from Setup.
- Redirect loops or a blank page. Try a private browser window, which rules out stale cookies and extensions. Then clear cookies for
salesforce.com. - MFA code rejected. Fix the phone clock, then use the next code.
- Logged in to the wrong org. Check the username shown under your profile icon. Use the Apex snippet above to confirm the org and user.
- Login works on the web but the CLI fails. Check that you ran
sf org login webfor this org, then runsf org list. If the alias shows as expired or missing, authorize again.
The next chapter covers troubleshooting in more detail. For now, you have what you need to enter the org reliably.
What you can now do
- Explain what My Domain is and read the parts of the URL.
- Log in at your My Domain URL with a username, password and MFA code.
- Look up your My Domain URL in Setup, in the address bar, or with Apex.
- Open the org from the CLI without typing a password.
- Use Login History to diagnose failed attempts.
Exercise
You type your email address, [email protected], and the correct password on your org's login page, but you get "Your login attempt has failed." Your username is [email protected]. What is the most likely cause, and where can you confirm what happened?
Show answer
You entered the contact email instead of the username, and Salesforce signs users in by username. Log in with [email protected]. After a successful login (or once the username is right), open Setup, then Login History, to see the attempt and its status, such as "Invalid Password".
Exercise
You are logged in and need your org's My Domain URL for a script. Name two ways to get it from inside the org, and say why you shouldn't share the output of sf org open --url-only.
Show answer
Use Setup, Quick Find "My Domain", which shows the current My Domain URL. Or run System.debug(URL.getOrgDomainUrl().toExternalForm()); as anonymous Apex and read the debug log. You can also read the host name from the browser address bar. The output of sf org open --url-only contains a session token, so anyone who has it can enter the org as you until it expires.