侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

What is the difference between 0.0.0.0, 127.0.0.1 and localhost?

2023-11-14 星期二 / 0 评论 / 0 点赞 / 51 阅读 / 2284 字

127.0.0.1is normally the IP address assigned to the "loopback" or local-only interface. This is a "f

127.0.0.1 is normally the IP address assigned to the "loopback" or local-only interface. This is a "fake" network adapter that can only communicate within the same host. It's often used when you want a network-capable application to only serve clients on the same host. A process that is listening on 127.0.0.1 for connections will only receive local connections on that socket.

"localhost" is normally the hostname for the 127.0.0.1 IP address. It's usually set in /etc/hosts (or the Windows equivalent named "hosts" somewhere under %WINDIR%). You can use it just like any other hostname - try "ping localhost" to see how it resolves to 127.0.0.1.

0.0.0.0 has a couple of different meanings, but in this context, when a server is told to listen on 0.0.0.0 that means "listen on every available network interface". The loopback adapter with IP address 127.0.0.1 from the perspective of the server process looks just like any other network adapter on the machine, so a server told to listen on 0.0.0.0 will accept connections on that interface too.

That hopefully answers the IP side of your question. I'm not familiar with Jekyll or Vagrant, but I'm guessing that your port forwarding 8080 => 4000 is somehow bound to a particular network adapter, so it isn't in the path when you connect locally to 127.0.0.1

 

0.0.0.0有几个不同的含义,但是在这种情况下,当一个服务器被告知要在0.0.0.0上侦听,这意味着“监听每个可用的网络接口”。 从服务器进程的角度来看,IP地址为127.0.0.1的环回适配器就像机器上的任何其他网络适配器一样,所以在0.0.0.0上要求监听的服务器也会接受该接口的连接。

希望能回答您问题的IP方面。 我不熟悉Jekyll或Vagrant,但我猜你的端口转发8080 => 4000是以某种方式绑定到一个特定的网络适配器,所以它不是在路径当你连接到本地到127.0.0.1

广告 广告

评论区