laravel 无法在 localhost:8000 上侦听(原因:无法分配请求的地址)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36831644/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:39:58  来源:igfitidea点击:

Failed to listen on localhost:8000 (reason: Cannot assign requested address)

laravellaravel-5

提问by kn3l

When I run php artisan serveon Ubuntu, the Laravel development server tries to start on http://localhost:8000/but fails with this error:

当我php artisan serve在 Ubuntu 上运行时,Laravel 开发服务器尝试在http://localhost:8000/ 上启动但失败并出现以下错误:

[Mon Apr 25 10:28:08 2016] Failed to listen on localhost:8000 (reason: Cannot assign requested address)

[Mon Apr 25 10:28:08 2016] 无法侦听 localhost:8000(原因:无法分配请求的地址)

My hosts file (/etc/hosts/):

我的主机文件 ( /etc/hosts/):

1 27.0.0.1   localhost 

How can this be fixed?

如何解决这个问题?

回答by ganesh kalje

That's usually because the port is in already in use, or not available on the current host.

这通常是因为该端口已在使用中,或者在当前主机上不可用。

You can use this command to run php artisan serve --port=8080

您可以使用此命令运行 php artisan serve --port=8080