You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 9中执行php artisan serve命令一段时间后报错求助

Hey there! I totally get how frustrating it is when your Laravel 9 dev server crashes after running for a bit—especially when you’re just getting your feet wet with the framework. Since you mentioned you have a screenshot but haven’t shared the exact error yet, let’s go through some common fixes that usually resolve this kind of issue with php artisan serve:

Common Troubleshooting & Fixes
  • Boost PHP’s execution time limit
    A lot of times, the server times out because PHP’s default execution window is too short. You can tweak this easily:

    • Add or update this line in your project’s root .env file:
      PHP_MAX_EXECUTION_TIME=300
      
    • Or find the max_execution_time setting in your php.ini file, set it to 300 (that’s 5 minutes) or higher, then restart your terminal/PHP service.
  • Swap to a more stable local server
    Laravel’s built-in serve command is lightweight, but it’s not the most reliable for long runs. Try these alternatives:

    • Use php -S localhost:8000 -t public/ in your terminal—it works similarly but often has better stability.
    • If you’re on Mac, give Laravel Valet a shot; for cross-platform, Laravel Homestead is a solid choice too.
  • Check for resource leaks or high memory usage
    Open Task Manager (Windows) or Activity Monitor (Mac) while the server’s running. If the PHP process’s memory usage keeps climbing, you might have a loop that’s not terminating, unoptimized database queries, or a buggy third-party package. Close any unnecessary apps/terminal tabs to free up resources, then restart the server.

  • Clear Laravel’s cached files
    Corrupted cache can cause all kinds of weird crashes. Run these commands to wipe it clean:

    php artisan cache:clear
    php artisan config:clear
    php artisan route:clear
    php artisan view:clear
    

    Restart the server after running these, and see if the issue goes away.

  • Verify your PHP version & update dependencies
    Make sure you’re running PHP 8.0.2 or higher (that’s the minimum for Laravel 9)—check with php -v in your terminal. Also, run composer update to refresh your project’s dependencies; sometimes a buggy package is the culprit.

If you can share the exact error message from your screenshot later, we can narrow this down even more!

内容的提问来源于stack exchange,提问作者Ahil Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 20:57:31