Vue project cannot enter the project using localhost:8xx0, but replacing localhost with 127.0.0.1 can enter.
Solution:
Enter the file
C:\Windows\System32\drivers\etc\hosts
Open the hosts file with notepad to edit it to see if there is any in the file
127.0.0.1 localhost
localhost 127.0.0.1
If not, add it, the specific addition position is as follows
# 127.0.0.1 localhost # ::1 localhost //Added code127.0.0.1 localhost localhost 127.0.0.1 127.0.0.1
After adding, you can use localhost to access normally!
Supplementary knowledge:
If you still have any questions, please refer to this article
The reasons and solutions for localhost cannot access 127.0.0.1
Sometimes when we debug a program, we will have some inexplicable and strange problems. Localhost cannot be accessed but 127.0.0.1 can be accessed is one of them.
I guess most people won’t think about the difference between localhost and 127.0.0.1. For example, I sometimes use http://localhost/ to access the local server web page, and sometimes use http://127.0.0.1/ to access it. I think they are just two different ways to express the local server. Just like a web page that can be accessed through a domain name or through an IP. Localhost represents the domain name, while 127.0.0.1 represents the IP address.
Is my understanding right? Let’s take a look at a more professional interpretation now.
The difference between localhost and 127.0.0.1's concept and working principle
To compare the differences between the two things, you must first understand the concepts of the two. So, let's start with the concept.
localhost: also called local, the correct explanation is: local server
127.0.0.1: The correct explanation in Windows and other systems is: local address (native server)
One is "local" and the other is "native". However, from these two words, the difference between the two cannot be compared. Let's take a look at how they work.
localhot: It is not transmitted through a network card, and it is not subject to network firewall and network card related restrictions.
127.0.0.1: It is transmitted through a network card. It relies on a network card and is subject to restrictions related to network firewalls and network card.
Through the comparison of the above concepts and working principles, I think everyone is now thinking about what is the difference between localhost and 127.0.0.1. The problem mentioned at the beginning of the article that localhost cannot be accessed but 127.0.0.1 can be accessed. The reason is that it is likely that when localhost is accessed, the system has access to the current user's permissions. When using IP, it means that the localhost is accessing the localhost through the network, which may involve the permissions of the network user.
In addition, we should understand a truth now, that is, it is best to use localhost for local services when setting up programs. localhost will not resolve to IP, nor will it occupy network card or network resources.
Localhost cannot access solutions that 127.0.0.1 can access
Generally speaking, ping localhost should be 127.0.0.1 , but sometimes the following things will appear:
>ping localhost reply from ::1: times<1ms reply from ::1: times<1ms reply from ::1: times<1ms
The address is not "127.0.0.1" at all, but "::1:"
>ping 127.0.0.1 normal reply from 127.0.0.1 : bytes=32 times<1ms reply from 127.0.0.1 : bytes=32 times<1ms reply from 127.0.0.1 : bytes=32 times<1ms
Cause analysis:
IPV6 protocol parses 127.0.0.1 to ::1 (127.0.0.1 ipv6 form)
Enter cmd Enter in the Vista Start menu and open the command prompt. Enter ping localhost by default and the returned packet is not 127.0.0.1 but ::1. This is the local address of Ipv6 format.
Solution 1:
Modify the host file and open the C:/WINDOWS/system32/drivers/etc/hosts file with Notepad to see if it contains:
127.0.0.1 localhost
If not, add it to see if you can access localhost.
Some contents of the host file
# 127.0.0.1 localhost # ::1 localhost 127.0.0.1localhost localhost 127.0.0.1
Solution 2:
1. Open Internert Information Management to check whether IIS is started, and the default website is already enabled;
2. Open http://127.0.0.1/ to see if you can access the default web page of IIS. If you can access it, it means that IIS has been successfully installed on the computer and may not be able to resolve localhost;
3. Start--Command (cmd)--ping localhost to see if it can be pinged. Return information from 127.0.0.1. If it is successful, it means that localhost can be parsed;
4. If the previous step is not successful, use Notepad to open the C:/WINDOWS/system32/drivers/etc/hosts file to see if it contains: 127.0.0.1 localhost. If not, add it to it and check whether you can access localhost.
5. Try pointing the home directory of the website to another directory or creating a new virtual directory, and create a new web page file in the new directory, for example, add it to the "Document" item of the default website as the default accessed web page, and re-enter the URL: http://localhost/ to see if it can be accessed.
6. If it still doesn't work, uninstall IIS and install it again.
Ideas to solve the problem:
1. Ping localhost, this is the key, see if it can be pinged, and then see which IP address you have resolved
2. Then check the hosts file of the machine to see if it has been modified. If it has been modified, it will be changed back to normal mode.
3. Solve the essence of the problem, ipconfig see if the network is normal, and if it is not normal, repair it
4. Use antivirus software or 360 and other repair software to scan to see if there are malicious plug-ins or viruses, and then remove them once and for all!
5. Use your brain more, find ways to solve problems, and be good at using search engines.
The above article solves the problem that the localhost port server of the VUE project refuses to connect and can only use 127.0.0.1. This is all the content I share with you. I hope you can give you a reference and I hope you can support me more.