'Unable to connect' error

DRSteele

Well-known Member
Joined
Mar 31, 2015
Messages
2,659
Office Version
  1. 365
Platform
  1. Windows
Can someone please help me with a Power Query problem that has cropped up?

In a query, I am now unable to connect after years of successful use. The error is titled "Unable to connect" and then says "Access to the resource is forbidden".

This query is in a worksheet, and it churns away and loads. But when I try in a new workbook (and even that workbook where it works) to connect here it produces the error.

https://www.hockey-reference.com/leagues/NHL_2025_games.html
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I was able to connect to your link successfully, and load a table to a worksheet without any problems using Power Query...
 
Upvote 0
Thanks for you reply.

It still fails for me. What can be done?
 
Upvote 0
If you try it with a brand new workbook, are you still unable to connect?

You could also check the permissions for your data source...

Excel Formula:
Ribbon >> Data tab >> Get and Transform Data group >> Get Data  >> Data Source Settings

Then select the data source, and click on Edit Permissions. This is what mine shows..

Edit Permissions.jpg


If yours is the same, you could always try clearing permissions, and then try connecting again.
 
Upvote 0
I get the same error message. Will fiddle around and see if it can be resolved with settings.
 
Upvote 0
If the table structure has been updated, such as changes to classes, IDs, etc. then it could cause weird issues. I am not talking about the case it can't find the previously used classes but somehow gets confused because of the structure changes - especially since the UI directly utilizes the Html.Table function with Web.Contents. I know this doesn't sound like it should twrow a "forbidden" error in the first place, but I wasn’t able to access the page through the interface either - I got the same “forbidden” error. However, the issue resolved as soon as I manually specified the correct Html.Table parameters in the Advanced Editor, and the forbidden error disappeared. Additionally, since the page is served as entirely static HTML, I would recommend using Web.BrowserContents instead of Web.Contents.

Give the following a try:

Power Query:
let
    Source = Web.BrowserContents("https://www.hockey-reference.com/leagues/NHL_2025_games.html", [WaitFor = [Selector = "table#games"]]),
    ExtractTable = Html.Table(Source, {{"Column1", "table[id='games'] > * > tr > :nth-child(1)"}, {"Column2", "table[id='games'] > * > tr > :nth-child(2)"}, {"Column3", "table[id='games'] > * > tr > :nth-child(3)"}, {"Column4", "table[id='games'] > * > tr > :nth-child(4)"}, {"Column5", "table[id='games'] > * > tr > :nth-child(5)"}, {"Column6", "table[id='games'] > * > tr > :nth-child(6)"}, {"Column7", "table[id='games'] > * > tr > :nth-child(7)"}, {"Column8", "table[id='games'] > * > tr > :nth-child(8)"}, {"Column9", "table[id='games'] > * > tr > :nth-child(9)"}, {"Column10", "table[id='games'] > * > tr > :nth-child(10)"}}, [RowSelector="table[id='games'] > * > tr"]),
    PromoteHeaders = Table.PromoteHeaders(ExtractTable, [PromoteAllScalars=true])
in
    PromoteHeaders

If you’re like me and prefer short codes, it can be simplified like below (simply generating the columns list for 9 columns):

Power Query:
let
    Source = Web.BrowserContents("https://www.hockey-reference.com/leagues/NHL_2025_games.html", [WaitFor = [Selector = "table#games"]]),
    Columns = List.Transform(List.Numbers(1, 9), each {"Column" & Number.ToText(_), "tr >:nth-child(" & Number.ToText(_) & ")"}),
    ExtractTable = Html.Table(Source, Columns, [RowSelector="table[id='games'] > * > tr"]),
    PromoteHeaders = Table.PromoteHeaders(ExtractTable, [PromoteAllScalars=true])
in
    PromoteHeaders
 
Upvote 0
If you try it with a brand new workbook, are you still unable to connect?

You could also check the permissions for your data source...

Excel Formula:
Ribbon >> Data tab >> Get and Transform Data group >> Get Data  >> Data Source Settings

Then select the data source, and click on Edit Permissions. This is what mine shows..

View attachment 120172

If yours is the same, you could always try clearing permissions, and then try connecting again.
Thanks, Domenic.

I tried clearing the permissions and then starting again. It fails, even in a new workbook.
 
Upvote 0
I'm assuming that you're able to get to that link using your web browser, correct?
 
Upvote 0

Forum statistics

Threads
1,224,755
Messages
6,180,766
Members
452,996
Latest member
nelsonsix66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top