php Artisan 错误:无法在 localhost:8000 上收听
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27900174/
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
Artisan Error: Failed to listen on localhost:8000
提问by byacer
I'm having problem starting my laravelinstallation. Whenever I type in the terminal 'php artisan serve' it responses me an error:
我在开始安装Laravel 时遇到问题。每当我在终端“php artisan serve”中输入时,它都会向我响应一个错误:
Failed to listen on localhost:8000 (reason:une tentative d'access un α socket de maniere interdite par ses autorisation d'access a 0t0 tent0e)
无法在 localhost:8000 上侦听(原因:une 暂定 d'access un α socket de maniere interdite par ses autorisation d'access a 0t0 tent0e)
any ideas on how to solve this?
关于如何解决这个问题的任何想法?
thanks in advance.
提前致谢。
img problem http://i.imgur.com/rOt3Lat.png
img 问题http://i.imgur.com/rOt3Lat.png
it's works now I just changed the listen port from 8000 to 8888 or any other port your services didn't use it
现在可以使用了,我只是将监听端口从 8000 更改为 8888 或您的服务未使用的任何其他端口
'php artisan serve --port="8888"'
'php artisan serve --port="8888"'
采纳答案by Koen van den Heuvel
Are there any other services running on port 8000?
端口 8000 上是否还有其他服务正在运行?
You can use this command on Windows:
您可以在 Windows 上使用此命令:
netstat -aon | more
or on Linux / OSX
或在 Linux / OSX 上
sudo netstat -plnt
to see what services are running. Then disable the service that is running on port 8000 or use another port.
查看正在运行的服务。然后禁用在端口 8000 上运行的服务或使用其他端口。
回答by mayorsanmayor
Fixing Error: Failed to listen on localhost:8000
(reason: Address already in use)
修复错误:无法侦听localhost:8000
(原因:地址已在使用中)
List processes with php in it
列出包含 php 的进程
ps -ef | grep php
ps -ef | grep php
Example output
示例输出
501 **9347** 393 0 1:29PM ttys000 0:00.21 php artisan serve
501 9351 **9347** 0 1:29PM ttys000 0:02.01 /usr/local/php5-5.6.14-20151002-085853/bin/php -S localhost:8000 .../laravel/server.php
501 9781 393 0 1:56PM ttys000 0:00.00 grep php
Then kill the process
然后杀死进程
kill -9 9347
kill -9 9347
回答by Hemamalini
List process using ps -ef | grep php
列出进程使用 ps -ef | grep php
Then below only works for me
那么下面只对我有用
kill -9 9347
which is a force kill of the process
这是进程的强制终止
501 9347 393 0 1:29PM ttys000 0:00.21 php artisan serve
Option 2:
选项 2:
If above not works, Change the default laravel serve port number if you can, like
如果以上不起作用,请更改默认的 Laravel 服务端口号,例如
php artisan serve --port=8088
回答by Nadim Tareq
8000 is the default port. Use instead of :
8000 是默认端口。使用代替:
php artisan serve --port=8005
回答by Shahrukh Anwar
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
回答by Alex Quintero
Use killall -9 php
and if you want to close other services use killall -9 node
or killall -9 mysql
使用killall -9 php
,如果您想关闭其他服务使用 killall -9 node
或killall -9 mysql
回答by jasenmichael
for me php -S localhost:8080 from the terminal in vs code will sometimes crash, but still be running in the background.
对我来说,来自 vs 代码终端的 php -S localhost:8080 有时会崩溃,但仍会在后台运行。
-9 to force kill did it for me thanks @hemss
-9 强制杀死为我做了这件事谢谢@hemss
I did
我做了
php -S localhost:8080
[Wed Dec 12 13:48:03 2018] Failed to listen on localhost:8080(reason: Address already in use)
then I..
然后我..
sudo netstat -plnt
find the process running on port 8080
找到运行在 8080 端口的进程
tcp 2 0 127.0.0.1:8080 0.0.0.0:* LISTEN 10312/php
then force kill it..
然后强制杀死它..
kill -9 10312
I get
我得到
[1] + 10312 killed php -S localhost:8080
then restart...
然后重启...
php -S localhost:8080
回答by Omid Ahmadyani
best way if you 8000 port is busy or you have more one project running is run your project in new port such as 8088 or another free port.
如果您的 8000 端口很忙或者您有多个项目正在运行,最好的方法是在新端口(例如 8088 或其他空闲端口)中运行您的项目。
php artisan serve --port=8088
回答by Nidhishanker Modi
The solution I found a problem we face several times in Ubuntu.
我发现了一个我们在 Ubuntu 中多次遇到的问题的解决方案。
*Failed to listen on 127.0.0.1:8000 (reason: Address already in use)*
What we do, we change the port, right?
我们做什么,我们改变端口,对吧?
This problem can be solved also in few seconds following below steps.
1. Open Terminal
2. **sudo su**
3. **netstat -plnt**
_find the process running on port 8080_
4. **kill -9 PROCESSNUMBER**
For more details, see my blog, click here
更多详情,请看我的博客,点击这里
回答by Domingo
If you have all your configurations ok in the .env file then you should:
如果您在 .env 文件中的所有配置都正常,那么您应该:
Use the answer from mayorsanmayorin this post to kill all php processes. Then php artisan config:clear
使用这篇文章中来自mayorssanmayor的答案来终止所有 php 进程。然后php artisan config:clear
Finally, php artisan serve
最后,php artisan serve
Good luck!
祝你好运!