I have a Laravel app in Virtualbox in the localhost aka 127.0.0.1:8000 and I want to connect from my host to the server.
Also, it will be great that anyone with the same network can connect to my localhost.
How can this be done?
You can pass the host while running the php artisan serve command.
For example, your network IP is 192.168.1.2
Then run the command like this
php artisan serve --host=192.168.1.2
Hope this will work for you.
Related
I have windows 10 and WSL ubuntu. I used to run
php artisan serve
from my ubuntu(WSL). Now I want to access my laravel app from other devices. Should I run
php artisan serve --host <IP ADDR> --port 80
from ubuntu terminal or should I run it in windows CMD? and which IP should I use? I see different IP from my ubuntu terminal(WSL) as compare to the IP addr from the windows CMD. I don't know what to use.
I already tried to run the code from CMD but I still can't access the app.
You should follow these steps:
1: Run artisan command like this:
php artisan serve --host 0.0.0.0 --port 8000
2: In your other device you should run first your pc IP address and then colon and port number like this:
10.0.56.23:8000
I always used Laravel valet for developing Laravel projects, but i was curios and wanted to try docker for the first time. After a lot of struggle i decided to ga back to Laravel valet, only to find out that the url i used with valet redirects to 0.0.0.0:8080.
0.0.0.0:8080 was the url docker exposed outside the container.
I removed docker completely from my mac. Stil got the same problem.
I've tried to run php artisan serve, but 127.0.0.1:8000 also redirects to 0.0.0.0:8080.
I've tried access other Laravel applications with valet, no problem.
With my host file is nothing wrong, and so is my network settings.
Here is my host file
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Why I can't connect to Homestead mysql when I use artisan serve build in server? Host, port is configured in .env to point at Homestead database.
Why I want artisan serve instead of Homestead server? I'm making Nuxt app with hotreload and I want to test in while on localhost:8000 port.
Right now I'm getting "SQLSTATE[HY000] [2002] Connection refused".
Oh after npm build on Homestead server connection to database working great... so it's not credentials problem.
Virtual machine IP... 192.168.10.10 instead of my main OS IP 127.0.0.1. Solved. Thanks to #devk.
I am using laravel framework in ubunto system and I want to remove port number from my url
write now I can access my web-project with this url
http://localhost:8000
and I want this url
http://localhost/
How can I do this?
80 is the default port number of http so you have to use this command to omit the port number:
sudo php artisan serve --host=localhost --port=80
You can try
sudo php artisan serve --port=80
If nothing else (e.g. Apache oder Nginx) uses port 80 you COULD start the development webserver like this
sudo php artisan serve --port 80
You can access the app via http://localhost/ afterwards
Note that this is ONLY for development and some kind of hack. Install a dedicated webserver (Apache, Nginx) for production :-)
Do not use php artisan server in your commandline and use full URL path in browsers address bar as follows
http://localhost/projectname/public
I have a PHP application running on homestead box. This application makes calls to another app that is running on glassfish on my localhost:8080.
When PHP application sends the request to localhost:8080, I am getting following error:
ConnectException in RequestException.php line 49:
cURL error 7: Failed to connect to localhost port 8080: Connection refused
Still I can make calls to localhost:8080 from web browser.Anyone has any suggestion?
Seeing how your application is running in Homestead (which by default is available on 192.168.10.10 and is forwarded to also be accessible on localhost:8000) your application running on Glassfish will not have access to it using localhost:8080. This is because localhost in your vagrant box (Homestead) is not actually the same localhost as on the host machine.
What you could do is grab the ip address from the host machine and connect to it from your application running in Homestead.
So here is how I could solve the problem. Vagrant is the guest machine running on my localhost as host machine. To access host from guest, you need to use gateway from VB.
I found this answer which helped me to access my application on localhost.