How can I access my Laravel app from another PC?

PhpLaravel

Php Problem Overview


I'm trying to access my Laravel app from another PC in the same network using IP address but I can't get it to work by accessing 192.168.1.101:8000 in my browser.

What should I do?

Php Solutions


Solution 1 - Php

Why don't you use Laravel's artisan for it? Very simple:

sudo php artisan serve --host 192.168.1.101 --port 80

Now from other computers, you can type: http://192.168.1.101

Do not forget to replace the IP with your own local one. That's it.

Note: The sudo is only needed if you wanna serve on port 80.

Solution 2 - Php

Access laravel using your IP address

php artisan serve --host 0.0.0.0 

Now you can access laravel server by http://laravel-server-ip-address:8000

If you want to change the port as well then

php artisan serve --host 0.0.0.0 --port 8101

Now your laravel server is http://laravel-server-ip-address:8101

Solution 3 - Php

  1. Go to httpd.conf in Apache folder and find the following lines:

    DocumentRoot "c:/wamp/www"
    <Directory "c:/wamp/www">
        # ...Stuffs in here
        Options Indexes FollowSymLinks
        # ...Stuffs in here
        AllowOverride All
        #
        # Controls who can get stuff from this server.
        #
        Require all granted
    </Directory>
    
  2. Then replace the last line within <Directory> tag for:

         Order Deny,Allow
         Deny from all
         Allow from 127.0.0.1
         Allow from ::1
         Allow from localhost
    </Directory>
    
  3. Add a virtual host for your laravel application, go to httpd-vhosts.conf and add the following lines:

    <VirtualHost *:80>
        DocumentRoot "D:/.../your-laravel-app-path/public"
        ServerName yourservername.dev
        <Directory "D:/.../your-laravel-app-path/public">
            AllowOverride All
    	    Order deny,allow
    	    Allow from all
    	    Require all granted
        </Directory>
    </VirtualHost>
    
  4. Restart all your apache services

This should do it, i'm using wamp on Windows and works for me.

Solution 4 - Php

Use this command in which ip address is ip-v4. Check ip-v4 from your wifi connection properties.

php artisan serve --host 192.168.10.15 --port 5000

Solution 5 - Php

  1. Find your machine local IP:

> ifconfig

  1. Go to project folder and type following command: > sudo php artisan serve --host your_ip --port your_port > > example: > > sudo php artisan serve --host 192.168.1.70 --port 8080

  2. Browse form other computer:

> 192.168.1.70:8080

Solution 6 - Php

You can do it by using laravel's built in command php artisan serve.

Follow the steps:

  1. Go to your project's root directory within command line.
  2. run php artisan serve

If you still can't access port 8000 or it is already in use then run:

php artisan serve --port 8383

And it should listen on new port you provided. Also you can set other options for this command. Look for the help php artisan help serve.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDNMView Question on Stackoverflow
Solution 1 - PhpMustafa Ehsan AlokozayView Answer on Stackoverflow
Solution 2 - PhpBhavsar1311View Answer on Stackoverflow
Solution 3 - PhpRobin CurbeloView Answer on Stackoverflow
Solution 4 - PhpAhsan KhanView Answer on Stackoverflow
Solution 5 - PhpSafaetul Ahasan PiyasView Answer on Stackoverflow
Solution 6 - PhpRaviraj ChauhanView Answer on Stackoverflow