I am encountering a persistent issue with my self-hosted n8n instance running in Docker. I am trying to configure Google Calendar OAuth2 credentials, but I am consistently getting an Error 400: redirect_uri_mismatch

The n8n Docker container is not updating the N8N_HOST environment variable even after editing docker-compose.yml and restarting the container. This is causing a redirect_uri_mismatch error when trying to connect to Google Calendar OAuth2, as n8n is generating an incorrect redirect URL. I’ve checked docker-compose.yml, the container’s interior, and tried various restart methods, but N8N_HOST still shows the old yourdomain.com value.

Steps I have taken to troubleshoot:

Verified that N8N_HOST and GENERIC_OAUTH2_REDIRECT_URI are correctly set in /root/n8n/docker-compose.yml.

  • Ensured I am restarting the container from the same directory as the docker-compose.yml file.
  • Tried stopping and removing the container (docker stop n8n, docker rm n8n) before running docker-compose up -d.
  • Checked for any globally set N8N_HOST environment variables on the server (env and printenv).
  • Checked for a .env file inside the n8n container using docker exec -it n8n sh and ls -a, but did not find a relevant .env file in the home directory.
  • Tried using docker-compose down --rmi all before docker-compose up -d.
  • Verified the authorized redirect URI in Google Cloud Console matches the GENERIC_OAUTH2_REDIRECT_URI in my docker-compose.yml.
  • Suspect the old N8N_HOST value might be persistent in a Docker Volume. I tried temporarily changing the volume mount in docker-compose.yml to a new directory, but the issue persisted.

Hi

Please use this command to view all environment variables in your Docker container and ensure they are set correctly:

docker exec -it n8n printenv

If you’re experiencing any issues, ensure the environment variables are set correctly in your docker-compose.yml file:

N8N_HOST=yourdomain.com
GENERIC_OAUTH2_REDIRECT_URI=https://yourdomain.com/oauth2/callback

Then

docker-compose down && docker-compose up -d

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