Can't connect n8n to Outlook

Hello community,

Describe the problem/error/question

I am unable to connect Outlook to n8n. After entering my login credentials in the workflow and attempting to connect Outlook, I receive the error message “ERR_CONNECTION_REFUSED” in a pop-up window.

What is the error message (if any)?

ERR_CONNECTION_REFUSED

Please share your workflow

Information on your n8n setup

  • n8n version: 2.13.4
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker compose
  • Operating system: Debian 13 (6.12.74+deb13+1-amd64) as a virtual machine

outlook auth can be finicky — usually happens when the oauth flow times out or the credential gets stale. try deleting the credential and recreating it fresh, sometimes that clears whatever oauth issue is causing the connection refused error.

The login credentials were created today and are valid. This has been verified multiple times.
Could it also be due to the redirect URL not specifying port 5678?

You should have configured the WEBHOOK_URL=https://your_domain/. If your instance is listening on the 5678 port without any load balancers in front of it, that would not work.

1 Like

Like this?

 n8n:
    image: n8nio/n8n:latest
    restart: always
    ports:
      - "5678:5678"
    #labels:
      #- traefik.enable=true
      #- traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      #- traefik.http.routers.n8n.tls=true
      #- traefik.http.routers.n8n.entrypoints=web,websecure
      #- traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      #- traefik.http.middlewares.n8n.headers.SSLRedirect=true
      #- traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      #- traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      #- traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      #- traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      #- traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      #- traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      #- traefik.http.middlewares.n8n.headers.STSPreload=true
      #- traefik.http.routers.n8n.middlewares=n8n@docker
    environment:
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_HOST=n8n.hiddendomain.de
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_SSL_CERT=/etc/ssl/cert.pem
      - N8N_SSL_KEY=/etc/ssl/key.key
      - N8N_RUNNERS_ENABLED=true
      - N8N_RESTRICT_FILE_ACCESS_TO=/files
      - NODE_ENV=production
      - WEBHOOK_URL=https://n8n.hiddendomain.de/
      - N8N_EDITOR_BASE_URL=https://n8n.hiddendomain.de/
      - GENERIC_TIMEZONE=Europe/Berlin
      - TZ=Europe/Berlin
      - N8N_SECURE_COOKIE=false
    user: "1000:1000"
    volumes:
      - n8n_data:/home/node/.n8n
      - /volume1/docker/n8n/local-files:/files

But you don’t have Traefik. In that case, you should set the instance to listen for the 443 port:

ports:
- "443:5678"

or use 443 port entirely with:

ports:
- "443:443"
- N8N_PORT=443

and remove this one:
N8N_SECURE_COOKIE

1 Like

Ports are now entirely 443 and now the error message “ERR_CONNECTION_REFUSED” appears.
Same error like in my thread creation because of the port (i guess).

Are you running the container as a root user? Port 443 is part of the privileged ports, and a non-root user can’t use them.
And do you have any other reverse proxies? Like nginx?

Check also logs with docker logs n8n

1 Like
docker inspect $(docker ps -q) --format '{{.Config.User}} {{.Name}}'

The Container is used by the user 1000, which is n8n, not root. We also don’t use a proxy.
Should i change the container user?

Yes, try commenting out the user: line of the config.

If this works, then you may try updating the config to the non-privileged port, like

ports:
- "443:8443"
...
- N8N_PORT=8443

But I’m not sure how to configure Docker with non-root users.

Nop. Test failed

New .yaml:

n8n:
image: n8nio/n8n:latest
restart: always
ports:
- “443:8443”
#labels:
#- traefik.enable=true
#- traefik.http.routers.n8n.rule=Host(${SUBDOMAIN}.${DOMAIN_NAME})
#- traefik.http.routers.n8n.tls=true
#- traefik.http.routers.n8n.entrypoints=web,websecure
#- traefik.http.routers.n8n.tls.certresolver=mytlschallenge
#- traefik.http.middlewares.n8n.headers.SSLRedirect=true
#- traefik.http.middlewares.n8n.headers.STSSeconds=315360000
#- traefik.http.middlewares.n8n.headers.browserXSSFilter=true
#- traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
#- traefik.http.middlewares.n8n.headers.forceSTSHeader=true
#- traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
#- traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
#- traefik.http.middlewares.n8n.headers.STSPreload=true
#- traefik.http.routers.n8n.middlewares=n8n@docker
environment:
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_HOST=n8n.hiddendomain.de
- N8N_PORT=8443
- N8N_PROTOCOL=https
- N8N_SSL_CERT=/etc/ssl/cert.pem
- N8N_SSL_KEY=/etc/ssl/key.key
- N8N_RUNNERS_ENABLED=true
- N8N_RESTRICT_FILE_ACCESS_TO=/files
- N8N_LOG_LEVEL=debug
- N8N_LOG_OUTPUT=file
- N8N_LOG_FILE_LOCATION=/etc/n8n/
- NODE_ENV=production
- WEBHOOK_URL=https://n8n.hiddendomain.de/
- N8N_EDITOR_BASE_URL=https://n8n.hiddendomain.de/
- GENERIC_TIMEZONE=Europe/Berlin
- TZ=Europe/Berlin
#- N8N_SECURE_COOKIE=false
#user: “1000:1000”
volumes:
- n8n_data:/home/node/.n8n
- /volume1/docker/n8n/local-files:/files
volumes:
n8n_data:

Ports that are listening:

lsof -i -P

COMMAND     PID USER FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd        700 root  6u  IPv4  11850      0t0  TCP *:22 (LISTEN)
sshd        700 root  7u  IPv6  11852      0t0  TCP *:22 (LISTEN)
nmbd        712 root 12u  IPv4  11902      0t0  UDP *:137
nmbd        712 root 13u  IPv4  11903      0t0  UDP *:138
nmbd        712 root 14u  IPv4  11917      0t0  UDP n8n.hiddendomain.de:137
nmbd        712 root 15u  IPv4  11918      0t0  UDP 10.1.15.255:137
nmbd        712 root 16u  IPv4  11919      0t0  UDP n8n.hiddendomain.de:138
nmbd        712 root 17u  IPv4  11920      0t0  UDP 10.1.15.255:138
nmbd        712 root 19u  IPv4  17804      0t0  UDP 172.17.0.1:137
nmbd        712 root 20u  IPv4  17805      0t0  UDP 172.17.255.255:137
nmbd        712 root 21u  IPv4  17806      0t0  UDP 172.17.0.1:138
nmbd        712 root 22u  IPv4  17807      0t0  UDP 172.17.255.255:138
nmbd        712 root 23u  IPv4  17808      0t0  UDP 172.18.0.1:137
nmbd        712 root 24u  IPv4  17809      0t0  UDP 172.18.255.255:137
nmbd        712 root 25u  IPv4  17810      0t0  UDP 172.18.0.1:138
nmbd        712 root 26u  IPv4  17811      0t0  UDP 172.18.255.255:138
dockerd     715 root 32u  IPv4  51119      0t0  TCP n8n.hiddendomain.de:42974->172.64.144.78:443 (ESTABLISHED)
smbd        759 root 28u  IPv6  12125      0t0  TCP *:445 (LISTEN)
smbd        759 root 29u  IPv6  12126      0t0  TCP *:139 (LISTEN)
smbd        759 root 30u  IPv4  12127      0t0  TCP *:445 (LISTEN)
smbd        759 root 31u  IPv4  12128      0t0  TCP *:139 (LISTEN)
sshd-sess  1075 root  7u  IPv4  13636      0t0  TCP n8n.hiddendomain.de:22->ITPC2.technology.local:56757 (ESTABLISHED)
sshd-sess  1125  n8n  7u  IPv4  13636      0t0  TCP n8n.hiddendomain.de:22->ITPC2.technology.local:56757 (ESTABLISHED)
docker-pr 12160 root  8u  IPv4  54440      0t0  TCP *:443 (LISTEN)
docker-pr 12165 root  8u  IPv6  54441      0t0  TCP *:443 (LISTEN)

How are you binding the SSL certificates?
The path N8N_SSL_CERT=/etc/ssl/cert.pem relates to the path inside the Docker container, so there should be something like:

volumes:
- /volume1/docker/n8n/ssl_certs:/etc/ssl

where the path /volume1/docker/n8n/ssl_certs should contain the files cert.pem and key.key

and check the n8n logs with docker logs n8n