Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Power BI "Your data source can't be refreshed because the credentials are invalid": test-connection error or real credential failure

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Microsoft's gateway troubleshooting page lists "Error: Your data source can't be refreshed because the credentials are invalid" for a case where the refresh works and only the gateway's test connection fails: you "were able to connect to and refresh the semantic model with no runtime errors", yet the error bar appears. Microsoft says: "If refresh completes properly and you don't experience runtime errors, you can ignore these test connection errors for data sources that require optional parameters." When a refresh really fails on credentials, the refresh history shows the data source's own message, for example Unable to Connect. Details: "Invalid connection credentials". Read the refresh history first to tell which case you have.

What the error means

Microsoft says the error "can occur when the gateway attempts a test connection, even if the credentials supplied are acceptable and the refresh operation is successful." If the latest refresh in the history succeeded, you have that case and there is nothing to fix.

If refreshes really fail, the message comes from the data source. Where the credentials live depends on the source. For an on-premises source through the gateway, Microsoft says: "you don't need to supply credentials, as they're defined for the data source by the gateway administrator". For cloud sources such as Azure SQL Database, you manage them in the Data source credentials section of the semantic model settings.

Credentials that were right once go stale. Microsoft says: "For some authentication methods, if the password you use to sign in to a data source expires or is changed, you need to change it for the data source in Data source credentials too." Its refresh scenarios page adds that cached credentials can expire, and that the Microsoft Entra ID OAuth token "expires in approximately one hour" while the service "waits for up to two hours when loading data", so a long load "can fail with a credentials error".

The test-connection case has its own cause. The gateway's connection test "currently omits optional parameters (for example, Snowflake warehouse, role, or other advanced settings) and some connectors require those values", so the test fails even though the credentials are good.

Likely causes

Cause What you see How to confirm
Test connection omits optional parameters The error bar appears, but the refresh completes Refresh history shows success
Password expired or changed at the source Refresh failures start on or after the change Refresh history failure date against the password change date
Wrong or stale credentials on the gateway data source Unable to Connect. Details: "Invalid connection credentials", and in Show details the source's own message, such as SQL Server's login failed text Failure details; the gateway administrator checks the data source
The account does not match the authentication method Login fails although the password is right Source sign-in with the same account and method
OAuth token expired in a long load Credentials error on loads over about an hour Load duration in refresh history
A cloud source merged with an on-premises source Credentials error for the cloud part Whether one query merges both kinds of source
The credentials belong to a different owner You cannot update them Semantic model owner in settings
Outdated gateway A GatewayNotReachable error when setting credentials Gateway version

Prove the cause before changing anything

Every step here only reads.

  1. In the workspace, select the semantic model, then select Refresh, then Refresh history. Microsoft says it shows "the status, start time, duration, and error message for each refresh attempt". Select the Show link beside a failure for more detail.
  2. Read the message the data source returned. Microsoft says that for SQL Server it looks like Login failed for user 'username'. Its advice: "Verify that you have the correct username and password. Also, verify that those credentials can successfully connect to the data source. Make sure the account that's being used matches the authentication method."
  3. Decide whether the refresh really failed. If the latest refresh in the history shows success and only the error bar appears, you have the test connection case.
  4. Find where the credentials live. In the semantic model settings, the Data source credentials section holds cloud and personal-gateway credentials. For an enterprise gateway they sit on the gateway data source under Manage connections and gateways.
  5. Compare the failure date with any password change on the source account, and check the load time of the last successful refresh against the one hour of the OAuth token.
  6. For an on-premises source, Microsoft says to use Power BI Desktop on the gateway machine to test the connection, and that "if you can't refresh in Power BI Desktop from the gateway computer, it's highly unlikely that a refresh through the gateway succeeds."

Example (illustrative): the "Sales model" of Example Pty Ltd imports from an Azure SQL database and is owned by user1@example.com. The password of the SQL login pbi_reader was changed on 1 December. From 2 December every refresh in the history fails, and Show lists Login failed for user 'pbi_reader'. There is no gateway, so the credentials sit in Data source credentials in the semantic model settings. The owner enters the new password there, and the next refresh succeeds.

Fix

Match the fix to the cause you proved.

Update the credentials in the semantic model settings

Microsoft's scheduled refresh page says: "If credentials have expired or changed, go to Data source credentials in the semantic model settings and re-enter them." Microsoft also says each user "can only have one set of credentials per data source, across all of the semantic models they own". Microsoft says a semantic model "can only have one owner" and that to update credentials on a model you do not own, you must first take over the model with the Take over button on its settings page. Taking over changes the owner, so that is a decision for the workspace admin and is not a step here.

First save the current state: write down the authentication method and account name that the data source currently uses, which semantic models use that source, and the time. The password is not shown, so keep the old one in your password manager until the refresh works.

Risk: the next change replaces the credentials used by every semantic model you own that uses this source. A wrong entry makes every one of those refreshes fail, and repeated failures can lead Power BI to disable the schedule.

In the semantic model settings, open Data source credentials and enter the correct credentials for the data source.

Risk, only if you back out: entering the earlier method and account replaces the corrected credentials, so the refresh fails again if the earlier ones are no longer valid.

To undo it, enter the authentication method and account you wrote down. The password for the old entry has to be typed again, and if that password is no longer valid the refresh keeps failing.

The credentials are on the gateway data source

Microsoft says: "Only gateway admins can add data sources to a gateway." Our own advice: ask the gateway administrator to correct the credentials on that data source, in Manage connections and gateways. The authentication methods are Basic, Windows or OAuth2. For Windows, "make sure the account has access on the machine". For OAuth2, "Any query that runs longer than the OAuth token expiration policy might fail."

Other causes, as Microsoft describes them

  • Cached credentials: "Clear your internet browser cache, then sign in to Power BI and go to https://app.powerbi.com?alwaysPromptForContentProviderCreds=true to force an update of your credentials."- A query that merges on-premises and cloud sources: Microsoft gives two options, adding a data source definition for the cloud source to the gateway, or enabling "Allow user's cloud data sources to refresh through this gateway cluster". The second gives less control over what the gateway connects to.
  • SharePoint Online through OAuth: "you must use the same account that you use to sign in to the Power BI service".
  • An outdated gateway: Microsoft says a GatewayNotReachable error when setting credentials "can be the result of an outdated gateway" and that the answer is to install the latest gateway and try again. The update steps, with their warning, are in Power BI "Your data gateway is offline or couldn't be reached": find why the gateway is offline.
  • The test connection exception: nothing to fix if refresh completes.

Confirm the fix

  1. The credentials section no longer shows the error bar.
  2. After the next scheduled refresh, Refresh history shows a completed refresh with no failure. This check only reads.

What to watch afterwards

Risks and limits

  • These commands have not been run or lab-tested.
  • Credentials are secrets. Keep them out of tickets and screenshots.
  • Microsoft's pages describe screens that change; check the current pages.

Sources