Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kazi-shahin's avatar

Artisan serve can not open Localhost

Hello, I'm new in Laravel. Running Ubuntu as my OS and LAMP is install in my laptop.

After create a new laravel project. Once I command php artisan serve, Browser can not open my laravel project. If I type http://localhost:8000 the browser error is, "Whoops, looks like something went wrong."

Anyone can cooperate please?

0 likes
26 replies
xingfucoder's avatar

Hi @Kazi-shahin, are you using Vagrant?

Try using the following --port param:

 php artisan serve --port=8000

Hope it helps you.

kazi-shahin's avatar

Hi, No Luck!!! Here is my Terminal : shahin@BluBird-Interactive:~$ cd /var/www/html/laravel/test shahin@BluBird-Interactive:/var/www/html/laravel/test$ php artisan serve Laravel development server started on http://localhost:8000 [Mon Dec 22 18:26:53 2014] 127.0.0.1:38988 Invalid request (Unexpected EOF) ^C shahin@BluBird-Interactive:/var/www/html/laravel/test$ php artisan serve Laravel development server started on http://localhost:8000 ^C shahin@BluBird-Interactive:/var/www/html/laravel/test$ cd .. shahin@BluBird-Interactive:/var/www/html/laravel$ laravel new blog Crafting application... Application ready! Build something amazing. shahin@BluBird-Interactive:/var/www/html/laravel$ cd blog shahin@BluBird-Interactive:/var/www/html/laravel/blog$ php artisan serve Laravel development server started on http://localhost:8000 ^C shahin@BluBird-Interactive:/var/www/html/laravel/blog$ php artisan serve --port=8000 Laravel development server started on http://localhost:8000

MThomas's avatar

@kazi-shahin are you using L5 or L4?

And do you only get that error, noting more is shown?

bashy's avatar

"Whoops, looks like something went wrong." is not helpful. If it's a browser error, click "Details" for the error message. If it's the Laravel error page, please state that.

If in doubt, screenshot it.

kazi-shahin's avatar

@bashy only "Whoops, looks like something went wrong" What should happen once I do command, "php artisan serve" ?

MThomas's avatar

@kazi-shahin looks like your server thinks it is in production mode, that is why it is not showing you the error. For the time being (not for forever), in config/app.php set 'debug' => true,. And show us the error stack that is generated.

If this does not show an error stack, revert the change and apply the change to config/local/app.php and check if the error stack is shown.

1 like
kazi-shahin's avatar

@MThomas Here is the Error: Error in exception handler: The stream or file "/var/www/html/laravel/test/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/laravel/test/bootstrap/compiled.php:9030

MThomas's avatar

The storage directory needs to be writable :)

kazi-shahin's avatar

What should happen once I do command, "php artisan serve"?

MThomas's avatar

You should be able to view your site.

You must set an app key in app.php, this should have been done when you installed the copy of laravel, but now you must do it manual.

kazi-shahin's avatar

I have created Laravel from terminal by typing, "laravel new name" Still I need to do it?

MThomas's avatar

If there is no random string set for key in config/app.php, you must generate one. I believe you can generate one with the artisan command php artisan app:key. But you can check that by running php artisan list or php artisan in your terminal.

kazi-shahin's avatar

What I need to do for this error: "Error in exception handler: The stream or file "/var/www/html/laravel/test/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/laravel/test/bootstrap/compiled.php:9030"

MThomas's avatar

For that I repeat my previous comment:

The storage directory needs to be writable :)

kazi-shahin's avatar

Thanks a lot. Writable permission is okay. Key Generate is okay.

What about the "Debug = true / false". Should I keep them true at least at my localhost, so that I can get the error ?

MThomas's avatar

In config/app.php you should set the debug => false (this is to prevent errors being shown in production mode).

In config/local/app.php you should set debug => true so errors are shown when in development/local mode.

What file is used is determined based on the environment you are in.

You should checkout these lessons/series, it will help you a lot in understanding laravel:

It is worth the 9 bucks :)

kazi-shahin's avatar

Hey, Thanks I got it. The issue is fixed. Thanks for the great suggestion.

adilogin's avatar

I have a similar problem , my error details after setting 'debug' = TRUE are:

RuntimeException in compiled.php line 6693: No supported encrypter found. The cipher and / or key length are invalid.

1/1 RuntimeException in compiled.php line 6693: No supported encrypter found. The cipher and / or key length are invalid.

miotelka's avatar

In your app aplication find files named ".env.example" and ".env". Those files has your key. If you don`t have ".env" even if you run this command:

php artisan key:generate

then copy your ".env.example" and rename it to ".env"

run again:

  • php artisan key:generate
  • php artisan serve
  • This should resolve the issue with "Woops" and key errors.

    These are my steps:

    in terminal:

  • laravel new app_name
  • cd app_name
  • composer update
  • php artisan serve
  • in browser:
  • localhost:8000
  • If this doesn't work:
  • go to the app_name folder, copy .env.example and rename it to .env and run in terminal:
  • php artisan key:generate
  • php artisan serve
  • go to the browser - works for me :)

    Shahrukh4's avatar

    It is because something already running on that port and you can change the port by command itself, by running following command

    php artisan serve --port 8001
    
    3 likes
    ikeamadi's avatar

    @SHAHRUKH4 - This just solved the problem in no time. Simple, straightforward and powerful. Changing the port number was all I needed to do!

    Please or to participate in this conversation.