6

I recently uploaded my laravel blog project on 000WebHost, after that I redirected to URL http://laravelcreativeblog.000webhostapp.com/, but I saw this error Whoops, looks like something went wrong., this error is displayed two times one after the other. So I googled that and finally I reached to the a solution that there is an error in APP_KEY which I found here /public_html/storage/logs/laravel.log and error at last is:

[2018-10-18 15:44:47] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at /storage/ssd1/217/7530217/public_html/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:42) [stacktrace]

So I generated Application Key from CMD by php artisan key:generate and put in the .ENV File but again getting that error. This is all I done, so any suggestions???

Salman Zafar
  • 3,844
  • 5
  • 20
  • 43
Usman Developer
  • 568
  • 8
  • 26
  • 1
    use php artisan key:generate command to generate key – Shanu k k Oct 18 '18 at 11:36
  • 1
    i guess this may be an issue of putting code in wrong directory OR mis matched configuration. So try to put debug code in the index.php file and die; this was you will get better idea. – Exception Oct 18 '18 at 11:37
  • 2
    Please see the last two line of my question. – Usman Developer Oct 18 '18 at 11:37
  • @Exception in local server its working very well, there is no error in there. – Usman Developer Oct 18 '18 at 11:38
  • 3
    @Shanukk bro I'm on the web server not on local server – Usman Developer Oct 18 '18 at 11:39
  • If you check the error log again after setting the application key, what's the new error? – fubar Oct 18 '18 at 11:42
  • 1
    @fubar the error is same. I think that I generated the App Key locally and then put into server so this is the error I think and 000webhost free service can't support SSH Shell, so any suggestion how to generate App_key into server – Usman Developer Oct 18 '18 at 11:43
  • @UsmanDeveloper you should manually specified the APP_KEY from .env into config/app.php and please try – Shanu k k Oct 18 '18 at 11:44
  • Make sure you move the application outside of your `public_html/` folder, because right now your entire application (including log files with database passwords) is public on the internet. If your host requires you to use the `public_html/` folder, then create a symlink from `public_html/` to `public/` – Travis Britz Oct 18 '18 at 11:44
  • 2
    The key doesn't HAVE to be generated via the php artisan command it's just a nifty way of doing it just generate own key and manually add it to the .env file. – Rimble Oct 18 '18 at 11:45
  • 1
    @Shanukk I have added APP_KEY into `config/app.php` not worked. – Usman Developer Oct 18 '18 at 11:50
  • 1
    @TravisBritz thanks, but it's now throwing this error `Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.` how to solve it i have moved out of publoic_html – Usman Developer Oct 18 '18 at 11:52
  • @UsmanDeveloper that's hard to answer without knowing what exactly you changed. Did you also create a symlink from `public/` to your web host's website root folder (`public_html/`)? – Travis Britz Oct 18 '18 at 12:03

2 Answers2

4

I fixed the error the error was that 000WebHost does not support .ENV file variables, so we must add all .env detials into config/app.php file and database details into config/database.php. Read the last FAQ here, https://www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323 for more details(only for 000WebHost).

Usman Developer
  • 568
  • 8
  • 26
3

When you receive "No application encryption key" error:

  1. be sure that you have .env file in root directory
  2. run php artisan key:generate
Aleksandrs
  • 1,488
  • 1
  • 14
  • 34
  • 2
    Thanks bro it worked and not throwing that error but now its throwing this error `Connection refused` and how I use php artisan migrate? – Usman Developer Oct 18 '18 at 11:58
  • 1
    what kind of connection? is your db up and running? – Aleksandrs Oct 18 '18 at 11:59
  • 1
    check that DB_CONNECTION, DB_HOST, DB_DATABASE, DB_PORT, DB_USERNAME and DB_PASSWORD is set correctly in .env file, I think this will fix your error ;) – Aleksandrs Oct 18 '18 at 12:01
  • 2
    `APP_NAME="Laravel Creative Blog" APP_ENV=local APP_KEY=base64:QQvJhT6HMVkOcTvDiP0jySIlHsMtq2JSGdcl5kREF1Q= APP_DEBUG=true APP_URL=http://laravelcreativeblog.000webhostapp.com/ LOG_CHANNEL=stack DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=id7530217_laravelcreativeblog DB_USERNAME=myUser` – Usman Developer Oct 18 '18 at 12:06
  • 1
    @UsmanDeveloper, you’re going to want to change your app key again now that you’ve just published it online. – fubar Oct 18 '18 at 12:25