Lost connection to MySQL server at 'waiting for initial communication packet', system error: 2

569

I recommend you check if you have a firewall (iptables) or some security software (apparmor / selinux) enabled and running. Also the error log would be helpful here.

This manual page can help you debug the problem.

Share:
569

Related videos on Youtube

Tarik S.
Author by

Tarik S.

Updated on September 18, 2022

Comments

  • Tarik S.
    Tarik S. over 1 year

    I am using Laravel Spatie response cache: https://github.com/spatie/laravel-responsecache and Multiple language (language switch..).

    How to fix: Preventing a request from being cached for language switcher route in Laravel.

    I tried to add: ->middleware('doNotCacheResponse'); in lang.switch route but without success...

    Route::get('lang/{language}', ['as' => 'lang.switch', 'uses' => 'LanguageController@switchLang'])->middleware('doNotCacheResponse');
    

    Expected results to prevent request when switching pages (links) between language to be cached....

    • Sathish D
      Sathish D over 10 years
      Can you check the value set for "AllowTcpForwarding" in your 'sshd config' file (found in /etc/ssh/ directory). If it is "no", try changing it to "yes" and restart the ssh server (sshd daemon) and try connecting again.
    • Adam G
      Adam G over 10 years
      I have both AllowTcpForwarding yes and PermitTunnel yes, I found these from early reports of the same issue.
  • Adam G
    Adam G over 10 years
    Just updated my answer, definitely an issue with my iptables. Any advice on a better set up?
  • Tarik S.
    Tarik S. over 5 years
    Thanks Artjom Heinz, Where I should add the second code you sent me: ResponseCache::forget('/some-uri'); ?! And please if you can see this problem how to solve it: github.com/spatie/laravel-responsecache/issues/156
  • Tarik S.
    Tarik S. over 5 years
    Hello, I am using laravel spatie response cache with my laravel app, when I add some new posts on my website, I dont see the new added post anywhere (on homepage, in posts index page listed). Why I dont see new added posts?! And how to solve this. I want to have cached homepage and all index pages but to see new added posts, articles etc?! What is solution for this ?! Thanks
  • Admin
    Admin over 5 years
    @TarikS. I was just pointing out that it's possible to remove specific URIs instead of deleting the entire cache. Whether or not that's something you should do, I don't know. Regarding your second question, I suspect you don't see changes because you're getting the cached response. If so, don't cache dynamic data. stackoverflow.com/questions/5658417/…
  • Tarik S.
    Tarik S. over 5 years
    Helo @Artjom Heinz, Yes I am getting cached response I am using spatie for all my routes except update/edit/delete, But when I add new posts/articles for example, I want to view new added articles on my index and show pages but now I dont see them, what should I do here. You said to not cache, do you mean that than I dont cache index homepage and show pages, but what should than I cache ?! thanks
  • Admin
    Admin over 5 years
    @TarikS.Yes. Simply put, you don't cache somemthing that changes frequently. Typically, you cache things that don't change. The thread I linked to in my last comment explains some caching strategies for dynamic data. If you insist on caching, then you should delete the related cache after changing the data. So maybe if you expect users to add new data very rarely it would make sense to cache but to delete the cache after soemthing has been added.
  • Tarik S.
    Tarik S. over 5 years
    yes that is great, for example I have index view page and with $posts , and users adding new data (posts) every 3 - 4 or 5 days, I want to use cache here but to to delete cache for that particular route (view) after new posts are added in database that is it. I havent seen anything related to this in spatie doc on github can you tell me how can I implement that in my route for example for my homepage for [email protected].... using SPATIE cache.... ...Thanks
  • Admin
    Admin over 5 years
    @TarikS. I've edited my answer with an example of how this could work.
  • Tarik S.
    Tarik S. over 5 years
    I see your updated answer, but it is about update function when I updating some previously added posts for example. But my concern is VIEW AND SHOW blade files. I explained everything here in this uploaded screenshot below what I need, spatie cache work well, site is fast and good but I have for example on some view blade pages some dynamic data 1 or 2 divs with dynamic data.
  • Tarik S.
    Tarik S. over 5 years
    See this: See this screenshot : imgur.com/a/GXPkvQg ;;"" I want to cache everything on this page (banners in header, navbar, head, footer, everything) except this div (Services) because this is only DYNAMIC on this page. That is what I ask you for...""
  • Tarik S.
    Tarik S. over 5 years
    Good example.... I want to Cache partials in laravel blade for example just some partials im blade.php where foreach loop is.. that is it...
  • Admin
    Admin over 5 years
    @TarikS. The package you are using caches the entire response. You can cache specific data with Cache::put('key', 'value', $minutes); as described here