Google Cloud OAuth Consent Scren Credential N8n

<I’m running N8N locally with Docker Compose and I’m trying to validate the credentials within N8N, but I’m getting an error when I try to log in to Google:
In the “Authorized redirect URIs” configuration, I’m entering the following: “http://localhost:5678/rest/oauth2-credential/callback
The one provided by N8N, “http://host.docker.internal:5678/rest/oauth2-credential/callback”, is not accepted by Google, and I found this solution in a tutorial. I believe it might be related to this part. Does anyone know if there’s something I missed in the configuration? Can anyone help me?

Describe the problem/error/question

What is the error message (if any)?

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:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Yes, this is a common issue when running n8n locally with Docker + Google OAuth. The problem is with how Google validates the Authorized redirect URI.

n8n generates a callback like: http://host.docker.internal:5678/rest/oauth2-credential/callback

  1. But Google doesn’t accept host.docker.internal it as a valid domain.
  2. You tried switching to http://localhost:5678/``..., which Google accepts, but then n8n may not map it correctly inside Docker unless configured.

Use localhost : http://localhost:5678/rest/oauth2-credential/callback

In your docker-compose.yml, set the following environment variable so n8n uses localhost instead of host.docker.internal

environment:

Restart n8n. Now, OAuth flows will use localhost and match Google’s configuration.

NOTE: Replace your port if running a different port.

1 Like

Thank you for your help. Since I’ve already built the workflow based on the current environment, if I change the environment as you suggested, I’ll have to reconfigure everything again, right? I’m at that stage now, and I worked all day yesterday, its not a big deal but i wouldn’t want to lose what I’ve already done.

No worries, First download the workflow as backup for security and safety reason.

you won’t lose your existing workflows. Changing those environment variables and restarting n8n only updates how OAuth redirect URLs are generated. Your workflows, nodes, and credentials already stored will remain intact

1 Like

That’s valid only if a volume in docker compose is configured. If not, then all data will be lost

1 Like

Good point

if you haven’t configured a Docker volume for /home/node/.n8n, your data won’t persist after a container restart. I recommend double-checking your docker-compose.yml and ensuring you have a volume set up. If it’s already there, you’re safe and won’t lose workflows.

1 Like

This leaves me with so many doubts. I understood your advice perfectly, but as a beginner on the platform, how can I tell if I have a volume set up in docker-compose.yml? Sorry if this is a basic question, but I’ve been struggling with this since yesterday using AI, and now I need to ask for help on the forum.

No worries, it’s not a basic question at all :slightly_smiling_face:. To check if a volume is set up in your docker-compose.yml, look for a section under the n8n service like this:

services:
n8n:
image: n8nio/n8n
volumes:

  • ./n8n_data:/home/node/.n8n

If you see a volumes line mapping something to /home/node/.n8n, that means your workflows, credentials, and settings are persisted outside the container.

If there’s no volume, your data will be lost when the container restarts. In that case, you should add the volume before restarting n8n to save your existing work

1 Like


Thank you so much. I see there’s already a volume set up. So, just to confirm, should I now edit the existing n8n environment variables in the .yml file directly with the data you sent me right?

Yes, that’s correct.

You can edit the existing environment variables in your docker-compose.yml directly to use localhost and the other settings I mentioned. Since you already have a volume set up, your workflows, credentials, and data will remain intact after restarting the container.

1 Like

Generally, Docker Compose is not for beginners… Even a bare Docker requires a little amount of technical knowledge. For others, n8n cloud is better to use.

1 Like

Thanks a lot for the help! :grinning_face:

1 Like

Thank’s for the tip!!

BTW… using localhost as URL for Google callback?

No https? And a valid domain?

1 Like

Sorry, just to avoid any chance of error, could you please confirm these last details for me:

  1. In the current environment, should this data: WEBHOOK_URL: http://host.docker.internal:5678 be replaced with this: N8N_EDITOR_BASE_URL=http://localhost:5678/, resulting in: WEBHOOK_URL: ``http://localhost:5678/? Or should I replace it completely exactly as you sent it, resulting in: N8N_EDITOR_BASE_URL=http://localhost:5678/?

  2. In the current environment, N8N_HOST: host.docker.internal should be changed to N8N_HOST: localhost. Is that correct?

  3. I noticed these three settings are not in the current environment. Should I insert them exactly as they are? Where exactly should they go? Also, there is an existing ports: "5678:5678" in the current environment. Should I delete it and set it up as you instructed, or should I just change it to port: 5678?

    • N8N_PORT=5678

    • N8N_PROTOCOL=http

    • N8N_API_BASE_URL=http://localhost:5678/

I’m currently doing some tests without a domain to demonstrate the platform to clients and create some workflows at no cost. I plan to migrate and set up a domain later. I just started on the platform yesterday and spent the whole day setting up this first agent. The goal is to show it handling customer service and performing various actions within Google.

Keep your existing WEBHOOK_URL and ports as they are. Add these exactly as new environment variables under environment: in your docker-compose.yml:

N8N_HOST=localhost
N8N_EDITOR_BASE_URL=http://localhost:5678/
N8N_API_BASE_URL=http://localhost:5678/
N8N_PORT=5678
N8N_PROTOCOL=http

Then restart the container. Your workflows and credentials will remain safe if a volume is set up for /home/node/.n8n

1 Like

I added it like this, but it didn’t work. Please check if the configuration is correct. I couldn’t restart Docker in the terminal due to a duplicate ‘HOST’ line.

I really appreciate your patience.

i’m stuck haha :smiling_face_with_tear:

Because you need to remove the first HOST variable

1 Like