admin管理员组文章数量:1335871
I am trying to create an autoplete search bar for a website I am making, but I keep running into the same issue. It functions as it should when I launch the Brackets live preview which prompts 127.0.0.1:..../.../.../ but when I press my home button which routes me to localhost:8080/.../.../, it doesn't seem to run the code. I think it has something to do with the jQuery call, telling the function in which circumstance to run, but I'm not entirely sure. I am using XAMPP.
function autoplete(inp, arr) { ... }
Why does this occur?
Can you explain the difference between the two?
I am trying to create an autoplete search bar for a website I am making, but I keep running into the same issue. It functions as it should when I launch the Brackets live preview which prompts 127.0.0.1:..../.../.../ but when I press my home button which routes me to localhost:8080/.../.../, it doesn't seem to run the code. I think it has something to do with the jQuery call, telling the function in which circumstance to run, but I'm not entirely sure. I am using XAMPP.
function autoplete(inp, arr) { ... }
Why does this occur?
Can you explain the difference between the two?
Share Improve this question asked Nov 26, 2019 at 15:37 Beastmode7843Beastmode7843 311 gold badge1 silver badge4 bronze badges 5-
1
localhost
is generally the address127.0.0.1
but the:8080
part means to connect to port 8080 instead of the default port 80. – Pointy Commented Nov 26, 2019 at 15:39 -
So
localhost:8080
is the same as127.0.0.1:8080
– Pointy Commented Nov 26, 2019 at 15:39 -
127.0.0.1:8080
will be the same aslocalhost:8080
, not plain127.0.0.1
. Port 8080 is a popular port to host things like angular apps, nodeJS scripts, et cetera. – Shilly Commented Nov 26, 2019 at 15:39 -
@Pointy @Shilly Ok, that makes sense. When brackets launches live preview, the url shows
http://127.0.0.1:49684/.../.../
Why does the autoplete work at that address, but nothttp://localhost:8080/.../.../
Can I provide any other information to be of help? – Beastmode7843 Commented Nov 26, 2019 at 15:43 - 1 A web server listens generally on only one port. Looks like your numeric address is using port 49684, not port 8080. A "port" is like a room number in a hotel: the hotel itself has a street address, but when you rent a room you get a particular room number – Pointy Commented Nov 26, 2019 at 15:45
3 Answers
Reset to default 0I think this can help you. A resume of that:
If you use 127.0.0.1, then (intelligent) software will just turn that directly into an IP address and use it. Some implementations of gethostbyname
will detect the dotted format (and presumably the equivalent IPv6 format) and not do a lookup at all.
Copy of this answer*
You are not using port 8080 when you access the site with ip so I assume your site is listening on port 80. Can you try http://localhost only without the port number
localhost will usually resolve to 127.0.0.1, but not always.
In normal configurations, localhost will point to either an address in the 127.x.x.x range (usually 127.0.0.1), or ::1 or similar if using IPv6. Some application implementations actually treat localhost specially, and when used can trigger a connection using something other than the IP stack (like shared memory, etc). Some IP stacks don't treat localhost as a special name, and you can manually have it resolve to any IP address you want. For example, by putting an entry into your hosts file.
But your problem is that when you used localhost, you specified port 8080, and when you used 127.0.0.1 you didn't specify a port, which would default to either 80 or 443 depending on if you used the http or https prefix.
127.0.0.1 is (usually) the equivalent of localhost 127.0.0.1:8080 is (usually) the equivalent of localhost:8080
本文标签: javascriptUnderstanding the difference between localhost8080 and 127001Stack Overflow
版权声明:本文标题:javascript - Understanding the difference between localhost:8080 and 127.0.0.1 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742397029a2467133.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论