Laravel Web Route Return 404 (cant Find Controller)

- 1 answer

I have seen many issues in the internet with this problem im having but they are all ver broad and hard to pin point exactly whats wrong with it, as there can be many variables to it, so I decided to list everything I have tried and maybe someone could help me.

URL trying to access


Directory app/Http/Controllers/DirManagements/GetDirs.php

namespace App\Http\Controllers\DirManagements;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class GetDirs extends Controller
    public function __construct()

    public function getResult()
        echo "hi";

Web route

Route::get('dirs', 'DirManagements\[email protected]');

PHP artisan route:list

Domain  | Method   | URI                        | Name | Action                                                     | Middleware                                                                                     
|       |GET|HEAD  | dirs                       |      | App\Http\Controllers\DirManagements\[email protected]      | web   

Nginx Sites-available file

server {
    listen 443 ssl;

    root /my-dir-to-web;
    index index.php index.phtml index.html index.htm index.nginx-debian.html;

    location / {
            try_files $uri $uri/ =404;
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
ssl_certificate /etc/letsencrypt/live/something/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/something/privkey.pem; # managed by Certbot



I dont know why laravel didnt include this to their installation docs when setting laravel up. added this to my nginx config and it worked.

location / {
     try_files $uri $uri/ /index.php$is_args$args;

# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php7-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;


There can be multiple things that can cause this. Try each of the following and let me know if it works:

  • Make sure you have restarted the Server after creating the route.
  • Make sure you have run the following commands to don't get any sort of cache issues:

    php artisan config:clear  
    php artisan cache:clear  
    composer dump-autoload  
    php artisan view:clear  
    php artisan route:clear