Laravel 服务在本地主机上获取 ERR_CONNECTION_REFUSED
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40412396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel serve getting ERR_CONNECTION_REFUSED on localhost
提问by Daniel Campos
I'm having an issue with my local laravel server. I'm building an API, and I need to test from another device, but the only url which is working is:
我的本地 Laravel 服务器有问题。我正在构建一个 API,我需要从另一台设备进行测试,但唯一有效的 url 是:
localhost:8000
If I try
如果我尝试
127.0.0.1:8000
or using my machine local IP
或使用我的机器本地 IP
192.168.0.6:8000
I have a ERR_CONNECTION_REFUSED from chrome (I tried with safari too). There is no 'blocking' extensions
我有一个来自 chrome 的 ERR_CONNECTION_REFUSED(我也尝试过 safari)。没有“阻塞”扩展
回答by Daniel Campos
I found the answer: artisan serve isolates the host, so if I want to specify it, I need to do:
我找到了答案:artisan serve 隔离了主机,所以如果我要指定它,我需要这样做:
php artisan serve --host=127.0.0.1
回答by loic.lopez
php artisan serve :
php工匠服务:
Laravel development server started on http://localhost:8000/
so you can only access to this server by http://localhost:8000/
所以你只能通过http://localhost:8000/访问这个服务器
回答by Paradigm
Open up the terminal window in your working directory and run
在工作目录中打开终端窗口并运行
php artisan serve
php artisan serve
You will then be able to access your laravel local development through your browser by using the URL http://localhost:8000
然后,您将能够使用 URL http://localhost:8000通过浏览器访问 Laravel 本地开发