In Kong Gateway, you cannot have two services bound to the exact same route — a route must be unique in terms of its combination of matching rules (such as paths, hosts, methods, etc.).
🚫 Why You Can’t Have Duplicate Routes
Kong uses the route’s matching criteria to determine which service should handle a request. If two routes have the same matching rules, Kong can’t disambiguate, which leads to a conflict error when trying to create the second route.
For example:
# Service A
curl -i -X POST http://localhost:8001/services/ --data name=service-a --data url=http://api-a
curl -i -X POST http://localhost:8001/routes --data name=route-a --data service.name=service-a --data paths[]=/api
# Service B
curl -i -X POST http://localhost:8001/services/ --data name=service-b --data url=http://api-b
curl -i -X POST http://localhost:8001/routes --data name=route-b --data service.name=service-b --data paths[]=/api
â›” The second POST /routes will fail with:
HTTP 409 Conflict – duplicate entry
✅ Workarounds / Alternatives
| Goal | Solution |
|---|---|
| Blue/Green or Canary Deployments | Use Kong Plugins (e.g., traffic-split, canary) or upstreams and targets instead of duplicate routes. |
| Different consumers/users hitting different backends | Use request transformers, ACLs, or Kong Enterprise Route-by-header/Route-by-consumer plugins. |
| Same path, different method or host | You can differentiate routes by methods[], hosts[], or headers. |
🧪 Example: Two Routes with Same Path, Different Hosts
# Route 1
curl -i -X POST http://localhost:8001/routes \
--data name=api-v1 \
--data paths[]=/api \
--data hosts[]=v1.example.com \
--data service.name=service-a
# Route 2
curl -i -X POST http://localhost:8001/routes \
--data name=api-v2 \
--data paths[]=/api \
--data hosts[]=v2.example.com \
--data service.name=service-b
These can coexist because their hosts[] fields are different.
🧠Summary
| Route Matching Rule | Must Be Unique For |
|---|---|
paths[] | Same host/methods/headers |
hosts[] | If combined with same path |
methods[], headers | Can disambiguate routes with same path |
If you’re trying to achieve load balancing, blue-green deployment, or AB testing between services at the same route — I can help you set that up using upstreams + targets or the traffic-split plugin.
Would you like an example?