I faced this issue when connecting my Mongodb service with the Nestjs service (in the same k8s node). Remember to assign 27017 port to both port: and targetPort: in MondoDB's service.yaml. If you assign port:, to something else, it will not work.