Routing doesn`t work - Symfony app

Posted March 22, 2020 14k views
NginxPHP Frameworks


I am trying to deploy my Symfony app to the Digital Ocean. The problem is with routing - the app cannot find my annotation routes in the Controller, so on requesting the response is default Symfony homepage.

My dev.log is :

request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException:                                                                                                       "No route found for "GET /"" at /var/www/coinwatch/vendor/symfony/http kernel/EventListener/RouterListener.php line 136                                                                                                                     {"exception":"[object (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /\" at /var/www/coinwatch/vendor/symfony/http-kernel/EventListener/RouterListener.php:136)\n                    [previous exception] [object] (Symfony\\Component\\Routing\\Exception\\NoConfigurationException(code: 0):  at /var/www/coinwatch/vendor/symfony/routing/Matcher/Dumper/CompiledUrlMatcherTrait.php:182)"} [] 

I have been following this guide

My source code (app is working correctly on my localhost) []

Here is my server block config file

server {
    listen 80;
    listen [::]:80;

    server_name coinwatch;
    root /var/www/coinwatch/public;
    index index.php;
    client_max_body_size 100m;

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

    location ~ \.php {
        try_files $uri /index.php =404;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        include fastcgi_params;

    location ~ /\.(?:ht|git|svn) {
        deny all;

On command

php bin/console debug:router 

it returns no routes

Thanks in advance.

edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Finally, I have fixed it. The problem was apparently in outdated composer packages. This command worked.

composer update --with-dependencies 

Initially, the previous command was failing because of lacking swapping memory. That was fixed by following commands.

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1

Since you say it works locally, my best guess would be a caching problem. Go and check /var/www/coinwatch/var/cache - does it have the proper permissions?

You can also try running bin/console cache:clear -vvv on the droplet and see what happens, perhaps the cache isn’t being generated properly.

Also check your codebase for hardcoded paths.

P.S. Why do you have a var/log folder inside public? Is that a custom thing, or is Symfony creating it? The var folder should generally be outside of public.

  • Thanks for the answer.

    I have checked it and all files in the var folder have the proper permissions. When there is incorrect permission (I have tried that) it returns a fatal error, so I guess this is no problem. I have deployed another app [] with the same process and here everything works fine. I am really confused.

    Clearing out the cache with that command didn`t help either. In my code, I had some hardcoded paths, but only to static files. It is fixed now but without change.

    Yes, the var/log folder inside the public was created by me for custom logging in development. I won’t need it anymore so I have removed it.

    Well, it looks like a cache problem, but at this moment I have no idea how to solve it.