Permission denied for a route implemented by a custom module Hello I have the same problem with the following code:

first_module.routing.yml:

first_module.content:
  path: '/first'
  defaults:
    _controller: 'Drupal\first_module\Controller\FirstController::content'
    _title: 'Hello world'
  requirements:
    _permission: 'access content'


and the Controller:

&lt;?php

/**
 *  @file
 *  Contains \Drupal\first_module\Controller\FirstController.
 */


 namespace Drupal\first_module\Controller;

 use Drupal\Core\Controller\ControllerBase;


 class FirstController extends ControllerBase {

   public function content() {
     return array(
       '#type' =&gt; 'markup',
       '#markup' =&gt; t('Hello world'),
     );
   }
 }


And I receive the same "Access Denied" error every time I try to access this page.
As suggested to me from @berramou the solution is:


  Add \ to Drupal\first_module\Controller\FirstController::content like
  \Drupal\first_module\Controller\FirstController::content and clear
  cash. – berramou 17 mins ago