[Bug]: Connect to predefined network doesn't work with services or docker based deploys
Error Message and Logs
While making docker compose for cadvisor, tried to connect to predefined network via ui, but no network was attached.
Steps to Reproduce
- Make docker compose file for cadvisor without any networks
- Press 'Connect to predefined network'
- Check the deployed docker compose file
- No predefined network attached (only internal private)
Example Repository URL
No response
Coolify Version
v4.0.0-beta.407
Are you using Coolify Cloud?
No (self-hosted)
Operating System and Version (self-hosted)
Debian 12
Additional Information
No response
Did you restart your service after you set the Connect To Predefined Network?
Same here, trying with supabase:
- Pressed "Connect to predefined network"
- Restarted service
- checked deployable docker compose file: network not attached.
Also for a custom docker compose project conntected via github app I tried the "Connect to predefined network", then afterwards in the deployable docker compose file I saw both an internal and the attached network. Is this as intended?
Same here, trying with supabase:
1. Pressed "Connect to predefined network" 2. Restarted service 3. checked deployable docker compose file: network not attached.Also for a custom docker compose project conntected via github app I tried the "Connect to predefined network", then afterwards in the deployable docker compose file I saw both an internal and the attached network. Is this as intended?
I don't think that it is intended and expected behavior. I don't have such a problem only with Github App deployments
Did you restart your service after you set the
Connect To Predefined Network?
Yeah, restarted several times, also tested with other services
can you show an image of what you are seeing, as all the connect to predefined network does is; it will add the containers to the coolify network, it does this when starting; it does not alter the compose file.
can you show an image of what you are seeing, as all the connect to predefined network does is; it will add the containers to the coolify network, it does this when starting; it does not alter the compose file.
What do you exactly want to see? Definitely no predefined network is attached. Neither in docker compose file nor when starting container (other containers can't communicate with that container, after I did it manually they can communicate). My image is cadvisor.
Can you paste or link to the compose file you are using
Yeah.
services:
cadvisor:
container_name: cadvisor
image: 'gcr.io/cadvisor/cadvisor:latest'
environment:
- 'CADVISOR_PORT=${CADVISOR_PORT}'
ports:
- '${CADVISOR_PORT}:${CADVISOR_PORT}'
command:
- '--enable_metrics=cpu,memory,network,sched,oom_event,diskIO,cpuLoad,app,percpu,perf_event,process,tcp,udp'
- '--store_container_labels=true'
- '--docker_only=true'
- '--port=${CADVISOR_PORT}'
privileged: true
volumes:
- '/:/rootfs:ro'
- '/var/run:/var/run:rw'
- '/sys:/sys:ro'
- '/var/lib/docker/:/var/lib/docker:ro'
- '/dev/disk/:/dev/disk:ro'
devices:
- /dev/kmsg
healthcheck:
test:
- CMD-SHELL
- "wget --spider --server-response http://127.0.0.1:${CADVISOR_PORT}/containers/ 2>&1 | grep 'HTTP' | grep '200' || exit 1"
interval: 10s
retries: 5
start_period: 10s
timeout: 15s
Can you paste or link to the compose file you are using
Done
@Forceres can you check /horizon make sure queues are empty then run the following in a terminal on the vps and leave open
docker events -f 'type=network'
then restart the service, and paste here the entries you see
@Forceres can you check /horizon make sure queues are empty then run the following in a terminal on the vps and leave open
docker events -f 'type=network'then restart the service, and paste here the entries you see
Ok, that's strange. I pressed 'Connect to predefined network', but my services couldn't connect to cadvisor, then I attached the network manually and it worked. Now I discarded manual approach and pressed 'Connect to predefined network' again with docker events -f 'type=network'. It connected to my network without manual approach (docker-compose doesn't contain network), but my services couldn't connect to cadvisor (prometheus couldn't scrape cadvisor metrics)
@Forceres if you are trying to connect to this service from another compose, you need to connect both to the same docker network
so either define your own network first, and when adding the services select your defined network , so they both go in the same one, or you need to tick connect to predefined on both, that way both get added to coolify network
@Forceres if you are trying to connect to this service from another compose, you need to connect both to the same docker network
so either define your own network first, and when adding the services select your defined network , so they both go in the same one, or you need to tick connect to predefined on both, that way both get added to coolify network
All my services except cadvisor already connected to 'shared' (predefined) network, and prometheus scrapes them (all services different compose files)
@Forceres if you are trying to connect to this service from another compose, you need to connect both to the same docker network
so either define your own network first, and when adding the services select your defined network , so they both go in the same one, or you need to tick connect to predefined on both, that way both get added to coolify network
Looks like 'Connect to predefined network' also has implicit behavior. I checked my services via docker inspect network and cadvisor also is in the list. But my services couldn't connect to it.
@Forceres the only thing it does, is connect the container to coolify network, nothing more
if it's there then the issue is elsewhere, what is the contents of the prometheus yml file? Have you checked the env are correct for setting the PORT in the compose? have you tried removing all the env and fixing the value?
to be clear (there is no issue with connect to predefined network)
@Forceres the only thing it does, is connect the container to coolify network, nothing more
if it's there then the issue is elsewhere, what is the contents of the prometheus yml file? Have you checked the env are correct for setting the PORT in the compose? have you tried removing all the env and fixing the value?
to be clear (there is no issue with connect to predefined network)
Ok, I'll be clear. If I manually insert my predefined network in compose file without 'Connect to predefined network', everything is ok. BTW, I switched coolify predefined network to mine
@Forceres the only thing it does, is connect the container to coolify network, nothing more
if it's there then the issue is elsewhere, what is the contents of the prometheus yml file? Have you checked the env are correct for setting the PORT in the compose? have you tried removing all the env and fixing the value?
to be clear (there is no issue with connect to predefined network)
BTW, here is prometheus part with cadvisor:
- job_name: cadvisor
scrape_interval: 5s
static_configs:
- targets:
- cadvisor:8081
I think you have mis understood what the option means. Maybe it is poor wording, but it means connect to docker network named coolify
So if all your services are in your own docker network, ticking this option does nothing
So either add the network to the compose as external, which you did above
Or for applications (dont think this works for services) you can add your network as a destination then pick that when adding your apps.
I think you have mis understood what the option means. Maybe it is poor wording, but it means connect to docker network named coolify
So if all your services are in your own docker network, ticking this option does nothing
So either add the network to the compose as external, which you did above
Or for applications (dont think this works for services) you can add your network as a destination then pick that when adding your apps.
Looks like it's working only with apps, I mean destinations. I've thought that it also works with services. But anyway, why services doesn't support this?
@Forceres it does work on services as well. At least on the latest version beta409.
If you have multiple destinations defined in coolify, it will ask you to what network you want to deploy your app. Your service however will still get deployed on its own isolated network. If you then enable Connect to Predefined Network it will then move your service to the selected destination / network, not the coolify network.
The tooltip is probably a bit misleading on that note, since it specifically mentions the coolify network, but the network it will connect to will depend on the destination/network you selected during the deployment process. As already mentioned.
@Forceres it does work on services as well. At least on the latest version beta409.
If you have multiple destinations defined in coolify, it will ask you to what network you want to deploy your app. Your service however will still get deployed on its own isolated network. If you then enable
Connect to Predefined Networkit will then move your service to the selected destination / network, not the coolify network. The tooltip is probably a bit misleading on that note, since it specifically mentions the coify network, but the network it will connect to will depend on the destination/network you selected during the deployment process. As already mentioned.
So, if it works with services and I choose the correct destination, it will work in my specific case, but it doesn't work. It works only if I attach the network manually in the compose file.
@Forceres Make sure you delete any network configurations from your compose if you still have any. Enable Connect To Predefined Network if it was disabled, and restart your service.
Now to troubleshoot: run on your server docker network ls and docker inspect container_name_or_id, make sure to replace container_name_or_id with the actual name or id of your services container. And share the outputs of those commands here please.
Also it might be good if you update your coolify as well. Since you mentioned initially that you are still on beta407.
I think the problem with DNS names (my prometheus.yml has cadvisor:8081), but DNS name of the predefined network doesn't contain cadvisor. But it has 'prometheus' as DNS name in my prometheus service with 'Connect to predefined network'.
{
"Networks": {
"b8ogwowcc8gkkc0ckscsgcc0": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"cadvisor-b8ogwowcc8gkkc0ckscsgcc0",
"cadvisor"
],
"MacAddress": "02:42:0a:00:05:02",
"DriverOpts": null,
"NetworkID": "8f435c1f07393dcf771d36e40eb24e6520e776e9fb94e55eec477337efe85b84",
"EndpointID": "89f249a382301856c0117ec06670882810fa97cfd43bd19328d81eb7c37f38b6",
"Gateway": "10.0.5.1",
"IPAddress": "10.0.5.2",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": [
"cadvisor-b8ogwowcc8gkkc0ckscsgcc0",
"cadvisor",
"53f97e2e354c"
]
},
"predefined-network": {
"IPAMConfig": {},
"Links": null,
"Aliases": [
"cadvisor-b8ogwowcc8gkkc0ckscsgcc0"
],
"MacAddress": "02:42:0a:00:03:0f",
"DriverOpts": {},
"NetworkID": "320dbc91994e57ae6635c832c37a893b9bf3c7b630edd22d35aac969a2d013fb",
"EndpointID": "28ee2e4606a6098e62bcccc79695e8899b18d84cf0654bee25d64cec8109e699",
"Gateway": "10.0.3.1",
"IPAddress": "10.0.3.15",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": [
"cadvisor-b8ogwowcc8gkkc0ckscsgcc0",
"53f97e2e354c"
]
}
}
}
@Forceres Can you run through those steps for prometheus as well?
I also have the same issue, that "Connect To Predefined Network" doesn't work (in my case with "Mattermost". Mattermost cannot connect to postgres db host. It works again when uncheck "Connect To Predefined Network" Version: v4.0.0-beta.409
hosts in the "coolify" network are just the default ones except one, so no collision: (docker network inspect -f '{{range .Containers}}{{.Name}} {{end}}' coolify):
coolify-db coolify-proxy o4kskgk48gsggg448cw4wwcw-184915508020 coolify-realtime coolify coolify-redis
Here are the logs:
2025-04-27T18:39:11.105296041Z {"timestamp":"2025-04-27 18:39:11.104 Z","level":"info","msg":"Successfully connected to cache backend","caller":"platform/service.go:193","backend":"lru","result":"OK"}
2025-04-27T18:39:11.105342882Z {"timestamp":"2025-04-27 18:39:11.104 Z","level":"info","msg":"Server is initializing...","caller":"platform/service.go:196","go_version":"go1.22.6"}
2025-04-27T18:39:11.105350384Z {"timestamp":"2025-04-27 18:39:11.104 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable"}
2025-04-27T18:39:11.117726151Z {"timestamp":"2025-04-27 18:39:11.117 Z","level":"error","msg":"Failed to ping DB","caller":"sql/sql_utils.go:76","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable","retrying in seconds":2,"error":"pq: password authentication failed for user \"n4UObvOcVOSNGcKd\""}
2025-04-27T18:39:13.119205030Z {"timestamp":"2025-04-27 18:39:13.118 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable"}
2025-04-27T18:39:13.130241923Z {"timestamp":"2025-04-27 18:39:13.129 Z","level":"error","msg":"Failed to ping DB","caller":"sql/sql_utils.go:76","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable","retrying in seconds":2,"error":"pq: password authentication failed for user \"n4UObvOcVOSNGcKd\""}
2025-04-27T18:39:15.131675007Z {"timestamp":"2025-04-27 18:39:15.131 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable"}
2025-04-27T18:39:15.143058067Z {"timestamp":"2025-04-27 18:39:15.142 Z","level":"error","msg":"Failed to ping DB","caller":"sql/sql_utils.go:76","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable","retrying in seconds":2,"error":"pq: password authentication failed for user \"n4UObvOcVOSNGcKd\""}
2025-04-27T18:39:17.143505536Z {"timestamp":"2025-04-27 18:39:17.143 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable"}
2025-04-27T18:39:17.155847212Z {"timestamp":"2025-04-27 18:39:17.155 Z","level":"error","msg":"Failed to ping DB","caller":"sql/sql_utils.go:76","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable","retrying in seconds":2,"error":"pq: password authentication failed for user \"n4UObvOcVOSNGcKd\""}
2025-04-27T18:39:19.157255289Z {"timestamp":"2025-04-27 18:39:19.156 Z","level":"info","msg":"Pinging SQL","caller":"sql/sql_utils.go:68","database":"master","dataSource":"postgres://%2A%2A%2A%2A:%2A%2A%2A%2A@postgres:5432/mattermost?connect_timeout=10&sslmode=disable"}
2025-04-27T18:39:19.168262515Z Error: failed to initialize platform: cannot create store: error setting up connections: pq: password authentication failed for user "n4UObvOcVOSNGcKd"
2025-04-27T18:39:19.168472501Z {"timestamp":"2025-04-27 18:39:19.168 Z","level":"error","msg":"failed to initialize platform: cannot create store: error setting up connections: pq: password authentication failed for user \"n4UObvOcVOSNGcKd\"","caller":"commands/server.go:75"}
@Koliham those logs show you trying to connect to service called postgres Unfortunately coolify-db service name is also called postgres and is in coolify network This ip is returned first by docker dns since numerically it is before your compose network ip So from logs you can see user auth fail as its trying to connect to coolify-db In such cases you can't use service name postgres in your service
Please note imo the coolify services should not be in the coolify network or at least there should be a seperate ingress/public network
I also have this issue (beta419). I have 3 stacks, all of them with "Connect To Predefined Network" checked. 2 of the 3 stacks work correctly and are connected to the coolify network. But the third stack will not connect, not matter what I try. All 3 stacks are deployed via docker-compose file. If I manually connect the network, then all is fine but this gets reset if I re-deploy via Coolify.
The only way I could get it to work was define the coolify network in my compose file;
networks:
coolify:
external: true
name: coolify
Same here! I'm trying to put the n8n service and the Redis database into the same network. No matter what I do — editing the Docker-Compose file or switching 'Connect to predefined network' to true — N8N still creates its own network.