Pitfalls encountered in building projects based on react and vite

The previous article introduced how to initialize a project based on react and vite,
but encountered a problem.
When starting the local service; the console reported an error:
insert image description here
From the console, it can be seen that this error is usually caused by a local DNS configuration problem. Here are some possible solutions:

  1. Make sure your local DNS is configured correctly. You can try a different network connection or change the DNS server in your local network configuration.

  2. Check your hosts file is configured correctly. You can search for the "hosts" file on your computer and open it, then check to see if there are any entries that map "localhost" to the wrong IP address. If there are, delete them and save the changes.

  3. Check your proxy configuration. If you use a proxy server, you can try disabling it and restarting the development server to see if that fixes the problem.

  4. Try using the IP address instead of "localhost" in the configuration of the development server. For example, you can change the

"start": "vite --host localhost"

change to

"start": "vite --host 127.0.0.1"。
  1. Try setting your browser to automatically detect proxy settings, or manually configure proxy settings, to see if that resolves the issue.

Check it step by step, press point 4, the problem is solved;

Guess you like

Origin blog.csdn.net/gkf6104/article/details/129628772