5

I have installed laravel by composer create-project laravel/laravel –-prefer-dist

after this run php artisan serve command to laravel project directory and get this result.

Laravel development server started: http://127.0.0.1:8000

But when i go to http://127.0.0.1:8000 in browser laravel project not running and give error

This site can’t be reached 127.0.0.1 refused to connect.

but http://localhost/laravel/public/ it is working. Can anyone tell me that what is proper way to run this laravel project.

Magecode
  • 225
  • 2
  • 6
  • 16

8 Answers8

19

Try to run in different port

php artisan serve --port=9000

and then try http://127.0.0.1:9000 will work.

As might be on port 8000 something already running on your system will not make it work.

And you can also run your laravel project without artisan serve command

If anyone wants to make the application public, the more easy and fastest way is:

  1. Rename the "server.php" file in root directory, in "index.php"
  2. Move your .htaccess from public folder to root directory
  3. Make your directory accessible to Apache2 (set all file permissions to 777).
Vishnu Bhadoriya
  • 1,655
  • 1
  • 20
  • 28
Naincy
  • 2,953
  • 1
  • 12
  • 21
0

At starting level, you can use url like this http://127.0.0.1:8000 with port-number. but in further level you must working with simple url like http://localhost/laravel/public/. One more thing - you should remove "public" keyword from url, so you access direct your root-project. Review this link - Laravel 5 - Remove public from URL

Amit-Inex Patel
  • 481
  • 3
  • 15
0

I had that problem too! And couldn't solve it. So I installed openserver from https://ospanel.io/ and put my site on the folder domains (Windows 10), then I just start Open Server and click "My Sites" and choose my site - it opened in my browser which set by default on Open Server program and click the folder on my browser cooled "public" and there you go -> your site is working. I now that isn't solve the problem with cmd and start thought cmd and server like http://127.0.0.1:8000, but you can take access to your local site through http://'your site'/public/'your pages' Good luck!

0

Changing the port will help. php artisan serve --port=9000 worked for me

Philcz
  • 45
  • 1
  • 1
  • 9
0

Try this

php -S 127.0.0.2:8000 -t public/

It will start your local development to http://127.0.0.2:8000 which will work great.

OR

You can try instead

php -S 127.0.0.1:8000 -t public/ It will work in any browser as compare to command php artisan serve which open url http://127.0.0.1:8000.

neeraj sharma
  • 135
  • 2
  • 4
0

Successfully landed to Laravel page by the following steps.

Note: This is after the successful installation and configuration.

Was in /var/www/html/

Created the project using the following command after Laravel installation successfully

$laravel new firstapp

here firstapp is my project

cd to firstapp (folder created with project creation with $laravel new firstapp)

serve using the following command

$ php artisan serve

The project ready to serve with the following statement as below Laravel development server started: http://127.0.0.1:8000

You can access the laravel page using the following URL

http:///firstapp/public/

0

Sometimes this occur when you have installed an anti virus software. Anti-virus deleting your "server.php" file. For that you can create an exception in anti-virus for "server.php" file or creating a "server.php". You can find relevant code for the file searching. Basically server refuse to connect occurs when the "server.php" deleted or removed from the file path.

0

Change port php artisan serve --port=9000 if not solved and facing the issue then restart the system.