N8n cloudflare self hosting 503 error consistently

Hi there,

i’m self hosting n8n with cloudfare and cloudflared and constantly get 503 errors when trying to access the website im hosting n8n on. I treid to follow the tips to check the html response body,

I dont see cloudflare or cloudflare-nginx in the response body HTML,

But when i inspect the HTML i see this:

Unsafe attempt to load URL [insert url here] from frame with URL chrome-error://chromewebdata/. Domains, protocols and ports must match.

What am I doing wrong and how can I fix this issue?

Thanks for the help!

Please share your compose file.
Mask out sensitive details

services:

postgres:

image: [image goes here]

environment:

  - POSTGRES_DB=n8n

  - POSTGRES_USER=n8n

  - POSTGRES_PASSWORD_FILE=\[password goes here\]

secrets:

  -\[secret goes here\]

volumes:

[volumes go here]

ports:

  - [ports go here]

restart: unless-stopped

healthcheck:

  test: \["CMD-SHELL", "pg_isready -U n8n -d n8n"\]

  interval: 30s

  timeout: 10s

  retries: 3

n8n:

image: \[image goes here\]

environment:

  - N8N_HOST=\[host url goes here\]

  - N8N_PORT=[port goes here]

  - N8N_PROTOCOL=https

  - WEBHOOK_URL=\[URL goes here\]

  - GENERIC_TIMEZONE=America/New_York

  - DB_TYPE=postgresdb

  - DB_POSTGRESDB_HOST=postgres

  - DB_POSTGRESDB_PORT=[port goes here]

  - DB_POSTGRESDB_DATABASE=n8n

  - DB_POSTGRESDB_USER=n8n

  - DB_POSTGRESDB_PASSWORD_FILE=\[secret goes here\]

  - N8N_ENCRYPTION_KEY_FILE=\[encryption file goes here\]

  - N8N_USER_MANAGEMENT_DISABLED=false

  - N8N_COMMUNITY_PACKAGES_ENABLED=true

  - N8N_TEMPLATES_ENABLED=true

  - N8N_ONBOARDING_FLOW_DISABLED=false

  - N8N_METRICS=true

  - N8N_LOG_LEVEL=info

  - QUEUE_HEALTH_CHECK_ACTIVE=true

secrets:

  \[secrets go here\]

ports:

  -\[ports go here\]

volumes:

 \[volumes go here\]

depends_on:

  postgres:

    condition: service_healthy

restart: unless-stopped

healthcheck:

  test: \["CMD", "wget", "--spider", "-q", "readiness url goes here"\]

  interval: 30s

  timeout: 10s

  retries: 3

  start_period: 90s

cloudflared:

image: \[inage goes here\]

restart: unless-stopped

command: \[tunnel confil yaml command goes here\]

volumes:

 \[volume credentials go here\]

depends_on:

  - n8n

volumes:

postgres_data:

driver: local

n8n_data:

driver: local

secrets:

[secrets go here]

file: .\[secret goes here\]

n8n_encryption_key:

file: \[encryption key goes here\]

The issue is N8N_PROTOCOL=https in your compose. When using Cloudflare Tunnel, Cloudflare handles SSL termination — the tunnel connects to your n8n container over plain HTTP internally. Setting N8N_PROTOCOL=https tells n8n to generate https:// URLs for itself, but the container isn’t actually serving HTTPS, which causes the mixed-content/503 error you’re seeing.

Fix: change to N8N_PROTOCOL=http and make sure N8N_HOST is just your domain (e.g. n8n.yourdomain.com) without any protocol prefix. Your WEBHOOK_URL should still be https://n8n.yourdomain.com/ since webhooks are accessed via Cloudflare externally.

Also double-check your Cloudflare Tunnel config points to http://n8n:[port] (the internal container address), not https://.

Hi @jht, welcome to the n8n community!
So, in your script it’s not possible to see the necessary data to evaluate.
Can you confirm if the n8n host is the same as the domain used in the tunnel, if the webhook has the correct and complete URL, and if cloudflared is pointing to the correct port. Also, I researched this and it’s recommended to avoid using double https between cloudflared and n8n at the beginning of debugging.

Try accessing n8n through the local port without cloudflare. If it works locally but breaks when public, then we confirm that the problem is in the configuration.

hi there thanks for the help,

quick follow up question which parameters should i check to confirm the n8n host is the same as the domain used in the tunnel? and if cloudflared is pointing to the right port as well as the webhook url . Thank you

if you mean the N8N_HOST and WEBHOOK_URL they are the same except the N*N_HOST doesn’t have https//, the WEBHOOK_URL the complete and correct URL with https:/[url goes here]

not sure how to check if cloudflared is pointing to the correct port .

Thank you

Hi there,

thanks for the help , I tried the above:

changed the N*N_PROTOCOL to http

N8N_HOST is just the domain without the http or https

the WEBHOOK_URL is full url with https/url

not sure the last point

I tried running the url again and still get 503 error, not sure what else could be the problem?

Can you test accessing n8n directly via the local port (e.g. http://localhost:5678) without cloudflare in front? If that works fine, the 503 is definitely a cloudflare tunnel config issue, not n8n itself.

If local works, run cloudflared tunnel info <your-tunnel-name> and check what address cloudflared is routing to - it should be http://localhost:5678, not https://. Also share the output of docker logs <n8n-container> when you hit the 503 - that will tell us if n8n is even receiving the request or if cloudflare is dropping it before it arrives.

Does this help?

these parameters exactly, N8N_HOST and WEBHOOK_URL
An extra point I would check is whether cloudflared and n8n are really on the same Docker network. If the tunnel is configured for http://n8n:5678, that name will only resolve if both containers are on the same Compose network. It’s also worth verifying that the tunnel service is using the correct public hostname in the ingress and if there’s a final fallback rule, for example service: http_status:404. A 503 error usually appears when the tunnel exists, but the internal origin configured in the ingress is not accessible.