Google Credential Errors

I am running into a problem where when i try to connect to Google, using nodes like Google Cloud Storage or even using HTTP node with Oauth2, the executions will time out and either say something about a “refresh token” or “socket hang up” error.

The weird part is that if I go into my credentials and click the “Sign into Google” button, then the node works perfectly. But that only lasts a short time and then it’s back to “refresh token” and “socket hang up” errors. So, I know it works, but for some reason the authentification/credential doesn’t stick for long.

Below are screenshots of the error and then of the node working a couple seconds later after clicking the “Sign in with Google” button again…

Does anyone have a solution to this so that the credentials stick?

n8n details are in the image below :slight_smile:


It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Stiehla

Please fill up the details asked by @n8n bot

It’ll help to resolve your issue

Possible Causes

  1. Google OAuth2 Token Expiration & Refresh Token Missing
  • Google issues access tokens that expire after 1 hour.
  • If the refresh token is missing or revoked, n8n cannot refresh the access token, causing failures after a short time.
  • Re-signing in manually temporarily fixes the issue because a new access token is generated.
  1. Google OAuth2 Scopes Are Not Persisting
  • If Google’s OAuth2 consent screen was not configured properly, the refresh token might not be issued persistently.
  • Some Google services only issue refresh tokens on the first authentication attempt.
  • If you re-authenticate frequently without fully revoking previous sessions, Google may revoke old refresh tokens.
  1. n8n Credential Storage Issue
  • If n8n is running in Docker or a restricted environment, credential persistence might not be working correctly.
  • Verify that the database storing credentials is not resetting or failing to persist refresh tokens.
  1. Google API Quotas or Revocations
  • If you’re hitting Google API quota limits, Google may reject token refresh requests.
  • Check Google Cloud OAuth2 settings to see if your client ID is being flagged.

Solutions & Fixes

Ensure OAuth2 Refresh Token is Persisting

  1. Delete and Recreate Google Credentials in n8n
  • Go to n8n Settings > Credentials.
  • Delete the Google OAuth2 credentials.
  • Click Add new credential > Google OAuth2 and re-authenticate.
  • Make sure to check the “Allow offline access” option.
  1. Ensure Google Cloud Project is Configured Correctly
  • Visit Google Cloud Console OAuth2.
  • Select your OAuth2 Client ID.
  • Ensure “Use in Web Application” is enabled and “Authorized Redirect URIs” includes:
    https://n8n.yourdomain.com/rest/oauth2-credential/callback
    (Adjust this URL if self-hosted with a custom domain)
  1. Manually Grant Persistent Refresh Token
  • Open Google OAuth2 Playground:
    OAuth 2.0 Playground
  • Click Settings (gear icon) and enable:
    • :white_check_mark: Use your own OAuth credentials
  • Enter your Client ID and Client Secret.
  • Select Google APIs you’re using (e.g., Google Drive, Google Cloud Storage).
  • Click “Authorize APIs”.
  • Copy the refresh token and store it.

Ensure n8n Can Store Refresh Tokens

  1. Check if n8n is Running in Docker or a Read-Only Mode
  • If running in Docker, ensure the n8n data volume is persistent:
docker run -it --rm \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n
  • If running in a cloud environment, ensure database storage for credentials is working.
  1. Check n8n Database for Credentials
  • If using PostgreSQL or SQLite, inspect the credentials_entity table to confirm tokens are being stored.

Fix Potential Google API Rate Limits

  1. Visit Google Cloud API Console.
  2. Select “OAuth2 Consent Screen”.
  3. Check if your app is in “Testing Mode” (this can revoke tokens after 7 days).
  • If so, publish it to production to prevent frequent token expirations.

n8n version: 1.69.2
self hosted with docker

I asked chatgpt and several other ai chats already, thanks.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.