Laravel localhost works, but heroku gives 500 error

前端 未结 6 2255
旧巷少年郎
旧巷少年郎 2021-02-15 13:18

I\'m working in a project that needs to convert some data from excel to database. This is working fine in local host with laravel, but when goes to heroku, it gives me a 500 int

相关标签:
6条回答
  • 2021-02-15 13:40

    For problem with key in heroku add this code in config/app.php:

    'key' => env('APP_KEY', 'SomeRandomStringSomeRandomString'),
    

    In terminal write this command

    heroku config:set APP_KEY=SomeRandomStringSomeRandomString
    
    0 讨论(0)
  • 2021-02-15 13:44

    After some more hours trying to figure out what is going on with the code, I discovered that it was a problem with the Apache timeout.

    I found the answer here.

    Credits: Eric Cope

    0 讨论(0)
  • 2021-02-15 13:45

    Try this heroku config:set APP_DEBUG=true then visit your app and see what's exactly is the error. Most likely is database connection failing or missing .env key.

    0 讨论(0)
  • 2021-02-15 13:50

    I discovered the why I had the 500 error. It was because I was putting date configuration wrong.

    So, this post solved my problem.

    During the study to find the error, I discoverd that laravel has a debug messages when deploy too. So I change the debug mode to true.

    directory: "laravel/config/app.php"

    /*
        |--------------------------------------------------------------------------
        | Application Debug Mode
        |--------------------------------------------------------------------------
        |
        | When your application is in debug mode, detailed error messages with
        | stack traces will be shown on every error that occurs within your
        | application. If disabled, a simple generic error page is shown.
        |
        */
    
        'debug' => env('APP_DEBUG', true),
    
    0 讨论(0)
  • 2021-02-15 13:50

    I also want to add that I encountered this as well, but it was because I forgot to add the APP_KEY for the Heroku app.

    0 讨论(0)
  • 2021-02-15 13:57

    Set 2 config variables in heroku with following commands:

    1 heroku config:set APP_DEBUG=true
    2 heroku config:set APP_KEY=RandomString

    After setting these keys you will be able to see the actual error instead of general 500.

    0 讨论(0)
提交回复
热议问题