Describe the problem/error/question
Every second attempt to test credentials for my gitlab-node failed inside my n8n-docker-container.
This is a DNS-issue, because a ping inside the docker-container also resolves to different IP-adresses.
ping gitlab.local
PING gitlab.local (192.168.1.166)
ping gitlab.local
PING gitlab.local (192.168.1.23)
ping gitlab.local
PING gitlab.local (192.168.1.166)
...
…you get the idea.
BUT inside my DNS-server there is right now only one domain IP-Adress-Record
And all my other docker-containers / computers get only the right IP (192.168.1.166) for gitlab.
And n8n gets still the old AND the new IP-adress….even, if i restart the hole system.
Most solutions how to solve this issue from the internet are not working inside the docker-container, because the tools are not available in unmodified n8n-container.
Does anyone here know a working solution for me?
Thanks!
# docker-compose.yml - Add DNS configuration to your n8n service
services:
n8n:
image: n8nio/n8n
# ... your existing config ...
# Option 1: Specify DNS servers directly (recommended)
dns:
- 192.168.1.1 # Your local DNS server
- 8.8.8.8 # Google DNS fallback
# Option 2: Add static host entry (if IP is fixed)
extra_hosts:
- "gitlab.local:192.168.1.166"
# Flush host DNS cache (run on Docker host)
# Ubuntu/Debian with systemd-resolved
sudo systemd-resolve --flush-caches
# or
sudo resolvectl flush-caches
# Restart Docker daemon
sudo systemctl restart docker
# Recreate container (not just restart)
docker-compose down && docker-compose up -d
// /etc/docker/daemon.json - Global Docker DNS config (alternative)
{
"dns": ["192.168.1.1", "8.8.8.8"]
}
# After editing daemon.json
sudo systemctl restart docker
docker-compose down && docker-compose up -d
Hi, sorry for my late answer,
but one comment helped me to guide me in the right direction: “Flush host DNS cache (run on Docker host)”
The issue was not in n8n-container or in my DNS-server or in the connection between them.
The rootcause was a undocumented DNS-cache on Docker-Host.
On my NAS there where no possibility to flush this cache (to low level).
But after i use a different virtual switch/gateway between docker-container and network-adapter the issue was gone. 