Cannot access localhost:8080 from laravel

大憨熊 提交于 2019-12-24 02:13:37

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/36295776/cannot-access-localhost8080-from-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!