D8: Cannot redirect user at onKernelRequest event I want to redirect the user at "onKernelRequest" event and I have this method:

  public function onKernelRequest($event) {
    // Restricts access to nodes (views/edit).
    if (!empty($event-&gt;getRequest()-&gt;attributes-&gt;get('node'))) {
      $nid = $event-&gt;getRequest()-&gt;attributes-&gt;get('node')-&gt;get('nid')-&gt;getValue()['0']['value'];
      if (!$this-&gt;accessCheckService-&gt;canUserAccessByNodeId($nid)) {
        $response = new RedirectResponse('/access-restricted-by-taxonomy-term');
        $response-&gt;send();
        return;
      }
    }


The response is being sent, but the user is not redirected to the given address (access-restricted-by-taxonomy-term). It seems that RedirectResponse takes no action at onKernelRequest event. How can I fix this?
Instead of sending the response yourself you can try to use the method setResponse() of $event:

$event-&gt;setResponse($response);