Authentication (failed)net::ERR_CONNECTION_CLOSED

Describe the problem/error/question

Does anybody know why I’m trying to connect my Google sheets in n8n using GCT, but when I’m going to create my credentials at n8n my first callback get (failed)net::ERR_CONNECTION_CLOSED, and then I have more callbacks tentatives but all of them get canceled.

What is the error message (if any)?

After about 5 times trying to connect, I receive the message:

n8n - OAuth Callback body { font-family: 'Open Sans', sans-serif; padding: 10px;} details.error { margin-bottom: 20px; } pre.reason { background: #f7f7f7; border: 1px solid #ddd; border-radius: 3px; padding: 10px; overflow: auto; overflow-wrap: break-word; white-space: pre-wrap;}

Error: The OAuth callback state is invalid!

More details
		</details>
	Failed to connect. The window can be closed now.
	<script>
		(function messageParent() {
			const broadcastChannel = new BroadcastChannel('oauth-callback');
			broadcastChannel.postMessage('error');
		})();
	</script>
</body>

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.0.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): I’m using the community version self-hosted at Equinix.
  • Operating system:

This issue typically occurs when there’s a problem with the OAuth callback URL or network connectivity during the authentication process. Here’s how to fix it:

1. Ensure your n8n instance is accessible from the internet (if self-hosted)

2. Verify the callback URL in your Google Cloud Console exactly matches n8n’s OAuth callback URL

3. Make sure your firewall isn’t blocking the connection

If you’re running n8n locally, try using a tool like ngrok to expose your localhost to the internet for testing.