无法通过IP地址访问本地主机 [英] Can't access localhost via IP address

查看:1357
本文介绍了无法通过IP地址访问本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看本地托管的网站(如果需要的话,请使用grunt serve).我可以通过http://localhost:9000/http://127.0.0.1:9000/来查看它,但是不能通过http://10.0.0.16:9000/来查看.

10.0.0.16是我的本地IP地址(来自ifconfig或系统偏好设置),但是我无法从托管它的设备或网络上的其他设备访问http://10.0.0.16:9000/上的本地托管内容. /p>

当我的计算机位于其他网络(仅在我的家庭网络上)时,使用本地IP地址访问本地托管站点没有任何麻烦.你有什么需要改变的想法吗?

解决方案

如果可以通过127.0.0.1(或localhost)而不是计算机的IP地址访问在自己的计算机上运行的服务器,则表示服务器软件配置为仅在localhost接口上侦听.这是一个配置项,为避免暴露可能不安全的服务器,许多服务器程序已预先配置为仅在本地主机上侦听.这样,您可以在公开服务器之前在本地安全地进行测试.

请注意,0.0.0.0的意思是监听此计算机上存在的所有接口",这很方便,但是如果计算机具有多个接口,则可能会导致安全问题.

I'm viewing a locally hosted website (using grunt serve, if that matters). I can view it via http://localhost:9000/ or http://127.0.0.1:9000/, but not via http://10.0.0.16:9000/.

10.0.0.16 is my local IP address (from ifconfig or System Preferences), but I cannot access my locally hosted content at http://10.0.0.16:9000/ from either the device that is hosting it or from other devices on the network.

I haven't had trouble using my local IP address to access locally hosted sites when my computer is on other networks, only on my home network. Do you have any idea what needs to change?

解决方案

If you can access a server running on your own machine via 127.0.0.1 (or localhost) but not via the computer's ip address, this means that the server software is configured to listen on the localhost interface only. This is a configuration item and to avoid exposing a potentially unsecure server many server programs come preconfigured to listen on localhost only. That way you can safely test locally before exposing the server.

Note that 0.0.0.0 means "listen on all interfaces present on this computer" which is convenient, but may cause security issues if the machine has multiple interfaces.

这篇关于无法通过IP地址访问本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆