Windows · Windows Server  ·  high  ·  Microsoft Office

Outlook cannot set up the account, or connects to the wrong server

Account setup fails, or Outlook keeps finding a mailbox on a server that is no longer used. Autodiscover checks several sources in a fixed order and stops at the first one that answers, so a stale answer early in that order wins over a correct one later.

What you see

"Outlook cannot complete the setup" or "We're having trouble connecting" on a mailbox that works in a browser. Or the account sets up but points at an old on-premises server after a migration, sometimes with a certificate warning naming a domain nobody recognises.

What is actually wrong

Autodiscover tries, in order: a policy-supplied XML, the Active Directory service connection point, https at the root of the mail domain, https at autodiscover.<domain>, an SRV record, and finally the Microsoft 365 endpoint. A leftover SCP in AD, or a web server at the domain root answering on 443, is enough to stop the sequence with the wrong answer.

Codes and articles

autodiscoverExcludeHttpsRootDomainExcludeScpLookupTest E-mail AutoConfigurationcannot complete setup outlook

Start here — find out which fix applies

A script that runs the 2 inspection commands from the write-up below and prints what each one returned. It reads the machine and changes nothing — every command that could write, delete, start or stop is excluded from it by construction. Run this first, then pick the fix its output points at.

Download the read-only diagnosticchanges nothing · safe to run before reading

Fixes (4)

Find out which step is answering
Outlook, as the affected user20 minuteslow riskreversible

Always start here. Autodiscover has a built-in test that shows the whole sequence and where it stopped, and guessing without it wastes hours.

  1. Hold Ctrl and right-click the Outlook icon in the notification area, then choose Test E-mail AutoConfiguration.

    This is the single most useful diagnostic for this fault and almost nobody knows it exists. It is hidden behind Ctrl because it is a support tool rather than a user feature.

  2. Enter the address, clear the Use Guessmart and Secure Guessmart Authentication boxes, leave Use AutoDiscover ticked, and press Test.

  3. Read the Log tab, not the Results tab. It lists every URL tried in order with the outcome of each, and the first success is the answer Outlook is using.

    The Results tab tells you what it found. The Log tab tells you where it found it, which is what you actually need in order to fix it.

  4. Note the URL of the first successful step. That is the thing to correct — everything after it is irrelevant.

Confirm it workedYou can name the exact step that is answering and whether the answer is correct.
If you need to undo itDiagnosis only — nothing is changed.
Deal with a stale service connection point
PowerShell on a domain-joined machine40 minutesmedium riskreversible

The log shows an internal Exchange URL being found, on a network where the mailbox has moved to Microsoft 365.

  1. List the service connection points published in Active Directory.

    PowerShell
    ([adsisearcher]'(&(objectClass=serviceConnectionPoint)(serviceClassName=ms-Exchange-AutoDiscover-Service))').FindAll() | ForEach-Object { $_.Properties.servicebindinginformation }

    A domain-joined machine checks AD before it checks DNS, and it trusts what it finds. A decommissioned Exchange server that was never cleanly removed leaves its SCP behind, and every domain-joined client keeps being sent to it.

  2. If the old Exchange server is genuinely gone, the SCP should be removed as part of decommissioning it. That is an Exchange administration task and should be done properly rather than by deleting objects by hand.

  3. As an interim measure on affected clients, tell Outlook to skip the SCP lookup.

    PowerShell
    $k='HKCU:\Software\Microsoft\Office\16.0\Outlook\AutoDiscover'New-Item $k -Force | Out-NullSet-ItemProperty $k -Name ExcludeScpLookup -Type DWord -Value 1
  4. Restart Outlook and run the AutoConfiguration test again to confirm it now moves past that step.

  5. Treat the registry value as temporary. It is a client-side workaround for a server-side problem, and it has to be deployed to every machine and every new build until the SCP is actually removed.

    This is the step that turns a two-week fix into a permanent piece of estate debt if it is skipped. Record it somewhere and remove it once the SCP is gone.

Confirm it workedThe AutoConfiguration log shows the Microsoft 365 endpoint answering and the account connects correctly.
If you need to undo itDelete the ExcludeScpLookup value to restore the normal lookup order.
Download this fix as a PowerShell script3 steps you do yourself · asks before each step
Check the DNS records the lookup depends on
PowerShell30 minuteslow riskreversible

Setup fails from any network, or the log shows a lookup failing at the DNS steps.

  1. Check the autodiscover record for the mail domain.

    PowerShell
    Resolve-DnsName autodiscover.yourdomain.com | Select-Object Name, Type, NameHost, IP4Address

    For Microsoft 365 this should be a CNAME to autodiscover.outlook.com. An A record pointing at an old server, or no record at all, is the usual finding.

  2. Check whether anything is answering at the root of the domain on 443, since that step comes first.

    PowerShell
    Test-NetConnection yourdomain.com -Port 443 | Select-Object RemoteAddress, TcpTestSucceeded

    A marketing website at the domain root will answer the https root-domain probe and return HTML rather than autodiscover XML. Outlook has to time out on it before moving on, which is why setup can take minutes and then fail.

  3. Check for an SRV record, which is the supported alternative when the root domain is in use.

    PowerShell
    Resolve-DnsName -Type SRV _autodiscover._tcp.yourdomain.com -ErrorAction SilentlyContinue
  4. Run Microsoft's remote analyser against the address, which tests the whole sequence from outside your network and reports each step.

    PowerShell
    Start-Process 'https://testconnectivity.microsoft.com/'
  5. Correct the records at the DNS provider. Allow for the TTL before retesting, and remember that a negative answer can be cached too.

Confirm it workedThe remote analyser passes, and a new profile sets up without manual settings.
If you need to undo itNote the previous DNS values before changing them. DNS changes propagate on their own schedule, so allow time before judging.
Download this fix as a PowerShell script1 step you do yourself · asks before each step
Clear client-side overrides someone left behind
PowerShell as the affected user20 minuteslow riskreversible

One machine behaves differently from the rest, or a certificate warning names an unexpected domain.

  1. Read the whole AutoDiscover key. Anything in it is an override somebody applied deliberately at some point.

    PowerShell
    Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Outlook\AutoDiscover' -ErrorAction SilentlyContinue

    ExcludeHttpsRootDomain, ExcludeHttpsAutoDiscoverDomain, ExcludeSrvRecord, PreferLocalXML and ExcludeExplicitO365Endpoint each remove a step from the sequence. A value copied from a forum years ago to fix something else is a common cause of a machine that will not set up now.

  2. Check the policy hive as well, which overrides the user one.

    PowerShell
    Get-ItemProperty 'HKCU:\Software\Policies\Microsoft\Office\16.0\Outlook\AutoDiscover' -ErrorAction SilentlyContinue
  3. Back up the key before clearing it, so you can put back anything that turns out to have been load-bearing.

    PowerShell
    reg export "HKCU\Software\Microsoft\Office\16.0\Outlook\AutoDiscover" "$env:USERPROFILE\Desktop\autodiscover-backup.reg" /y
  4. Remove the overrides that are not deliberate, then restart Outlook and retest.

    PowerShell
    Remove-Item 'HKCU:\Software\Microsoft\Office\16.0\Outlook\AutoDiscover' -Recurse -Force -ErrorAction SilentlyContinue
Confirm it workedThe AutoConfiguration log runs the full sequence and lands on the correct endpoint.
If you need to undo itDouble-click autodiscover-backup.reg to restore the previous values.

Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.