I’m having trouble getting my n8n workflow to connect to a local MCP server I built using FastAPI MCP. No matter what configuration I try, the connection keeps failing.
What I’ve verified
I already tested my MCP server with MCP-Inspector and it works fine. I also connected to it successfully from Cursor IDE, so I know the server itself is functioning properly.
The error I’m seeing
When I try to use the MCP Client node in n8n, I get a connection error saying it cannot reach my MCP server.
My Docker setup
I’m running n8n in Docker with this command:
docker run -it --rm --name n8n_instance \
-p 5678:5678 \
-v n8n_storage:/home/node/.n8n \
-e N8N_SKIP_RESPONSE_COMPRESSION=true \
docker.n8n.io/n8nio/n8n
I added the compression skip flag because I read somewhere that gzip might interfere with SSE transport, but it didn’t help.
System details
- n8n Version: 1.94.1
- Platform: Docker self-hosted
- Node.js: 20.19.1
- Database: sqlite
- License: enterprise production
I’ve looked through several forum posts and GitHub issues but haven’t found a working solution yet. Has anyone else run into this issue with MCP Client nodes?
Update - Fixed!
Turns out the problem was my server URL. I was using http://localhost:8000/mcp which points to localhost inside the Docker container, not my host machine. Changing it to http://host.docker.internal:8000/mcp solved the issue completely!
Classic Docker networking gotcha that trips up tons of developers. When n8n runs in a container, localhost points to the container itself, not your host machine where the MCP server lives. You’ve got the right idea with host.docker.internal - that works perfectly on Windows and macOS with Docker Desktop. Linux users need a different approach though. Either use --network host in your Docker run command or just use your host machine’s actual IP instead of host.docker.internal. You can also add --add-host=host.docker.internal:host-gateway to your Docker run command - creates the hostname mapping no matter what OS you’re on. This container vs host networking confusion gets everyone at some point.
Good catch on the networking issue. I hit the same problem with MCP connections from Docker containers. Check your firewall settings too - your Docker version and host OS matter here. Sometimes the MCP server works fine from other host apps but Docker blocks it because it’s using different network interfaces. If host.docker.internal doesn’t work, try ip route | grep docker0 on Linux to find your actual host IP, or just use your machine’s LAN IP directly in the URL. Also make sure your MCP server binds to 0.0.0.0 instead of 127.0.0.1 - localhost only accepts local connections.
so true! that localhost thing has tripped me up too, especially with Docker… it’s always the simple stuff that gets ya. thanks for sharing your fix, im sure it’ll help others!