{"record":{"id":"87f4cfcf4a01e54d","repo":"puppetlabs/puppet","slug":"failed-to-start-the-service","errorCode":null,"errorMessage":"Failed to start the service","messagePattern":"Failed to start the service","errorType":"exception","errorClass":"Puppet::Util::Windows::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/windows/service.rb","lineNumber":52,"sourceCode":"    end\n    module_function :exists?\n\n    # Start a windows service\n    #\n    # @param [String] service_name name of the service to start\n    # @param optional [Integer] timeout the minumum number of seconds to wait before timing out\n    def start(service_name, timeout: DEFAULT_TIMEOUT)\n      Puppet.debug _(\"Starting the %{service_name} service. Timeout set to: %{timeout} seconds\") % { service_name: service_name, timeout: timeout }\n\n      valid_initial_states = [\n        SERVICE_STOP_PENDING,\n        SERVICE_STOPPED,\n        SERVICE_START_PENDING\n      ]\n\n      transition_service_state(service_name, valid_initial_states, SERVICE_RUNNING, timeout) do |service|\n        if StartServiceW(service, 0, FFI::Pointer::NULL) == FFI::WIN32_FALSE\n          raise Puppet::Util::Windows::Error, _(\"Failed to start the service\")\n        end\n      end\n\n      Puppet.debug _(\"Successfully started the %{service_name} service\") % { service_name: service_name }\n    end\n    module_function :start\n\n    # Stop a windows service\n    #\n    # @param [String] service_name name of the service to stop\n    # @param optional [Integer] timeout the minumum number of seconds to wait before timing out\n    def stop(service_name, timeout: DEFAULT_TIMEOUT)\n      Puppet.debug _(\"Stopping the %{service_name} service. Timeout set to: %{timeout} seconds\") % { service_name: service_name, timeout: timeout }\n\n      valid_initial_states = SERVICE_STATES.keys - [SERVICE_STOPPED]\n\n      transition_service_state(service_name, valid_initial_states, SERVICE_STOPPED, timeout) do |service|\n        send_service_control_signal(service, SERVICE_CONTROL_STOP)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/windows/service.rb#L34-L70","documentation":"Raised by Puppet::Util::Windows::Service.start when StartServiceW returns FALSE after the service handle was opened and its state validated. StartServiceW fails for concrete Win32 reasons: the service is disabled, a dependency failed to start, access denied (handle opened without SERVICE_START), or the service is marked for deletion. The appended Win32 text and e.code identify which.","triggerScenarios":"Calling start on a service whose start type is SERVICE_DISABLED (error 1058), whose dependencies are not running (1068), on a service marked for deletion (1072), or when the process token lacks the service-start right (5). Also fires if the service binary itself fails to launch.","commonSituations":"Manifest sets ensure => running but the service's enable/start-type was left disabled and not changed in the same run; ordering issues where a dependency service is not yet up; agents running under accounts without permission to start the service.","solutions":["Check e.code: 1058 = service disabled, 1068 = dependency failure, 1072 = marked for deletion, 5 = access denied","Set the startup type to enabled (e.g. set_startup_configuration with :SERVICE_AUTO_START or manual) before calling start","Ensure dependency services are running first, or subscribe/require them in the manifest","Run from an elevated context with rights to start the service"],"exampleFix":"// before\nPuppet::Util::Windows::Service.start('myservice')\n\n# after\nPuppet::Util::Windows::Service.set_startup_configuration('myservice', startup_type: :SERVICE_DEMAND_START)\nPuppet::Util::Windows::Service.start('myservice')","handlingStrategy":"validation","validationCode":"raise Puppet::Error, 'service missing' unless Puppet::Util::Windows::Service.exists?(name)\nstart_type = Puppet::Util::Windows::Service.service_start_type(name)\nif start_type == :SERVICE_DISABLED\n  Puppet::Util::Windows::Service.set_startup_configuration(name, startup_type: :SERVICE_DEMAND_START)\nend","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Util::Windows::Service.start(name)\nrescue Puppet::Error => e\n  # detail in message carries the win32 cause; e.g. 1058 disabled, 1068 dependency\n  raise Puppet::Error, \"start(#{name}) failed: #{e.message}\" \nend","preventionTips":["Check service_start_type and flip disabled to manual/auto before calling start","Ensure dependencies are running first; order manifest resources accordingly","Read the inner win32 code from the error detail to pick the right fix"],"tags":["windows","service","win32","startservice"],"backgroundTag":"windows-service-start-failed","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}