I’m running into a weird problem with Docker containers in GitHub Actions. My setup works perfectly on my local machine but breaks when running in CI/CD pipeline.
The issue happens when trying to connect to a containerized service. On my local setup everything connects fine, but in GitHub Actions I get connection refused errors.
Here’s my docker-compose configuration:
workflow_service:
image: docker.n8n.io/n8nio/n8n
ports:
- "3000:5678"
environment:
- N8N_HOST=workflow_service:5678
- N8N_PORT=5678
- N8N_PROTOCOL=http
- NODE_ENV=production
- DB_TYPE=postgresdb
- DB_TABLE_PREFIX=workflow_
- DB_POSTGRESDB_DATABASE=automation
volumes:
- ./config/service/data:/home/node/.n8n
- ./config/service/files:/files
When my Python application tries to make HTTP requests to the service, it fails with connection errors in GitHub Actions but works locally. I’ve tried different port mappings and checked if the ports are already in use.
The error shows that the service isn’t accepting connections on the expected port. Has anyone encountered similar networking issues with Docker containers in GitHub Actions?
i agree with what you said, switching to workflow_service:5678 makes sense. also, make sure the service is fully up before you try connecting. might be worth adding a wait step in your actions to give it time to start.
The N8N_HOST environment variable is likely causing your issue. You’re setting it to workflow_service:5678 but that’s not how the host should be configured. The N8N_HOST should typically be set to 0.0.0.0 or left undefined to bind to all interfaces within the container. The service name resolution works differently in GitHub Actions compared to local Docker environments. Try removing the N8N_HOST variable entirely or set it to 0.0.0.0. Also verify that your Python application is connecting to http://workflow_service:5678 from within the Docker network, not localhost:3000. The port mapping only applies when accessing from outside the Docker network.
Check your GitHub Actions workflow file to ensure you’re using the correct networking setup. GitHub Actions runs containers differently than your local Docker environment, particularly with network isolation. If you’re running your Python application outside of the Docker Compose network in the workflow, you’ll need to connect via localhost:3000, but if it’s inside the network, use workflow_service:5678. Another common issue is that GitHub Actions may not preserve the same network context between steps. Consider running both your application and the n8n service within the same Docker Compose setup in your workflow, or explicitly create a shared network. Also double-check that your workflow is actually starting the services with docker-compose up before your application attempts to connect.