When press connect my account I go through the following steps:
- A new page with the code_challenge in the URL opens, I see my hubspot account and can choose it
- I see the available scopes (view details about invoices etc) and can select these
- When I press Connect App I get the following errror
Error: Request failed with status code 500
More details
Failed to connect. The window can be closed now.
There are no further details on the config or in the browser. Any assistance with this would be greatly appreciated, as I understand the MCP server is in Beta. Thankyou.
The 500 error is likely due to a handshake failure caused by your n8n instance not recognizing its own public address. Since you are self-hosting, do double-check that your WEBHOOK_URL environment variable is set to https://n8n.mydomain.com/, matching your redirect URI base.
Hello thankyou for this. Our env is setup with the webhook url correctly (with our actual domain instead):
# -- Webhook node configurations
webhook:
# -- Use `regular` to use main node as webhook node, or use `queue` to have webhook nodes
mode: queue
# -- Webhook url together with http or https schema
url: “https://n8n.mydomain.com”
GiantFocal’s suggestion about the WEBHOOK_URL is a good first check. On top of that, since you’re using PKCE grant type, one thing worth verifying is whether the token exchange endpoint is actually expecting PKCE or a standard authorization code flow. HubSpot’s MCP server is still in beta and I’ve seen cases where the OAuth implementation doesnt fully support PKCE yet even if the authorize step accepts the code_challenge. The 500 on the token request (not a 400 or 401) suggests the server itself is failing to process something, not just rejecting your credentials.
A couple things I’d try. First, check if n8n is sending the code_verifier correctly in the token request body. You can inspect the outgoing request in n8n’s execution log or with your browser dev tools. Second, try switching the grant type to a standard Authorization Code flow (without PKCE) as a test to see if the token exchange succeeds. If it does, then you know the issue is specifically with how HubSpot’s MCP beta handles the PKCE verification step. Also worth checking that your client secret isnt being sent alongside the PKCE parameters since some implementations choke when they receive both.
Since MCP is beta, I’d also recommend opening a ticket with HubSpot support and referencing the 500 error specifically. A 500 is a server side failure on their end and theres only so much you can debug from your side. We’ve had similar experiences at Stacksync when integrating with newer HubSpot API features, sometimes its just a matter of waiting for a fix on their side. Note This response was written based on my own experience and lightly reformatted with AI for clarity.