“localhost refused to connect” Adding Gmail to Classic Outlook

Published by Nyau Wai Hoe - Updated on

Adding a Gmail or Google Workspace account to classic Outlook on Windows 11 or 10 normally takes one quick sign-in in your browser, and Outlook does the rest. Instead, after you allow access on Google’s page, the browser ends on “localhost refused to connect” (sometimes with localhost:8011 and ERR_CONNECTION_REFUSED), or it says the sign-in is complete while Outlook keeps telling you the account needs attention. This guide will help you get the account connected again.

Also see: How to Add Gmail Account to Mail App in Windows 11

"localhost refused to connect" Adding Gmail to Classic Outlook

Why does Outlook end up on a “localhost refused to connect” page?

When you add a Google account, classic Outlook sends you to Google’s sign-in page in your browser. Once you allow access, Google hands the sign-in back to Outlook through a local address on your own PC, localhost:8011. If nothing picks up that hand-off, the browser shows “localhost refused to connect” and Outlook never gets the sign-in.

localhost refused to connect error page Outlook Gmail sign-in

When adding the account fails like this, it usually comes down to one of these:

  • The permission box on Google’s page was left unticked, so Outlook didn’t get access to your mail.
  • An old or broken saved sign-in for that account is still stored in Windows.
  • Extra entries in the hosts file, left behind by an old program, a VPN or a proxy.
  • A temporary problem on Google’s or Microsoft’s side, in which case there’s nothing to fix on your PC.

First, check if it’s a temporary Google or Microsoft problem

If the browser shows Google’s “This app has reached its sign-in rate limit for now” page with “Error 403: rate_limit_exceeded“, the problem isn’t your PC. Several people hit this on November 12 and 13, 2026, around the same time as a large Outlook outage, and for some it cleared on its own about a day later. Stop retrying for a while, since every attempt counts toward the limit, and try again later, or the next day if it still fails. If Outlook mail isn’t working at all, check https://status.cloud.microsoft for an outage.

Update Outlook and retry with the permission box ticked

According to Microsoft, the Gmail sign-in fails when the box on Google’s “Select what Microsoft apps & services can access” page isn’t ticked. That box reads “Read, compose, send, and permanently delete all your email from Gmail“, and Outlook can’t sync your mail without it. Newer versions of Outlook (Current Channel Version 2412, Build 18324.20168 or later) also add a Retry link to the error window.

  1. In Outlook, go to File > Office Account and click Update Options > Update Now. Let Office finish, then reopen Outlook.Update Outlook classic via Office Account Update Options
  2. Click the Sign in via browser bar or the Retry link in the error window (or add the account again with File > Add Account).
  3. On Google’s page, tick the “Read, compose, send, and permanently delete all your email from Gmail” box before you continue.

If Outlook stops asking you to sign in and starts syncing the account, you’re done.

Remove the saved Google sign-ins from Credential Manager

Outlook keeps each Gmail account’s sign-in as two entries in Windows’ Credential Manager. When those go bad, Outlook keeps using them instead of a new sign-in. Removing them forces a clean sign-in, and it’s what fixed it for several people on Reddit.

  1. Close Outlook.
  2. Search for “Credential Manager” in the Start menu and open it.
  3. Click Windows Credentials.Windows Credentials in Credential Manager Windows 11
  4. Under Generic Credentials, look for entries that start with MicrosoftOffice16_Data:OAUTH2. Expand each one: the Gmail ones have tp_google_imap_Oauth2 in their full name.
  5. Click Remove on both entries for the Gmail account that doesn’t work. If you can’t tell which entries belong to which account, remove all the Gmail ones and sign in to each account again.
  6. Open Outlook, click the Sign in via browser bar (or File > Add Account if you removed the account), and tick the permission box on Google’s page.

The account should then reconnect and download mail again.

Might be useful: How to Forget Samba (SMB) Credentials in Windows 11/10

Remove Microsoft’s access in your Google Account

Microsoft’s own fix also removes Outlook’s access on Google’s side, so Outlook gets a brand new sign-in from Google next time.

  1. Close Outlook.
  2. Go to google.com, click your profile picture and select Manage your Google Account.
  3. Click Linked apps on the left, and find Microsoft apps & services in the list (or type it in the search box).Google Account Linked apps search Microsoft apps and services
  4. Open it, click Delete all and confirm.
  5. Open Outlook and sign in to the account again, ticking the permission box.

If Outlook now syncs instead of showing the localhost page, that was it.

Check the hosts file for leftover entries

The hosts file tells Windows where certain addresses point. Old test tools, VPNs and proxies sometimes add lines to it and never remove them. Cleaning them out has fixed the localhost error for some people.

  1. Search for “Notepad” in the Start menu, right-click it and choose Run as administrator.
  2. Click File > Open, go to C:\Windows\System32\drivers\etc, set the file type to All files, and open hosts.
  3. In a default hosts file, every line starts with #, even the two localhost lines at the bottom. Remove any line that doesn’t start with # and that you didn’t add yourself, especially extra 127.0.0.1 entries, and save.Open hosts file in Notepad as administrator Windows 11
  4. If there’s a hosts.ics file in the same folder, put a # in front of each line with mshome.net in it and save.
  5. Restart your PC and try the sign-in again.

Linked issue: Access Denied When Editing Hosts File in Windows 11/10

Restart, or use a different default browser for the sign-in

Outlook opens Google’s page in your default browser. For a related problem, where the Allow button on Google’s page is greyed out, Microsoft suggests restarting the PC first and, if that doesn’t help, temporarily switching your default browser, adding the account, then switching back.

To change it, go to Settings > Apps > Default apps, pick the other browser and click Set default.

Default apps settings change default browser Windows 11

Then add the account in Outlook again, and switch your default browser back once it’s syncing.

Pro tip: How to Set Chrome as Default Browser in Windows 11

Set the account up manually with an app password

As a last resort, skip the browser sign-in and connect with a Google app password. Google doesn’t recommend it, it needs 2-Step Verification on your Google Account, and work or school Workspace accounts often can’t create one.

Outlook’s own Add Account sends a Gmail address straight to Google’s sign-in, even when you pick IMAP, so use the older setup window in Control Panel instead:

  1. Create an app password at https://myaccount.google.com/apppasswords and copy it.
  2. Close Outlook, open Control Panel, type “Mail” in its search box and open Mail (Microsoft Outlook).
  3. Click Email Accounts… > New…, choose Manual setup or additional server types, click Next, choose POP or IMAP and click Next again.
  4. Fill in Your Name and Email Address, set Account Type to IMAP, enter imap.gmail.com in Incoming mail server and smtp.gmail.com in Outgoing mail server (SMTP), use your full Gmail address as the User Name, and paste the app password into Password.IMAP account settings Gmail in Outlook classic
  5. Click More Settings …. On the Outgoing Server tab, tick “My outgoing server (SMTP) requires authentication” and keep “Use same settings as my incoming mail server“.
  6. On the Advanced tab, use port 993 with SSL/TLS for the incoming server (IMAP), and 465 with SSL/TLS (or 587 with STARTTLS) for the outgoing server (SMTP). Click OK, then Next to test and finish the setup.

Outlook then connects without the browser, so the localhost page can’t appear.


Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 15 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.