How to fix error occurred while trying to proxy request

Milan Stanojevic
by Milan Stanojevic
Deputy Editor
Affiliate Disclosure
Share this article:

  • If you’re an advanced PC user, you’re most likely familiar with how the proxy works.
  • Many developers reported Error occurred while trying to proxy request message in their projects, but there’s a way to fix this issue.
  • Want to learn more about proxies? This dedicated Proxy server article has all the information you need.
  • Having additional problems on your PC? Our Fix Hub has more in-depth guides that can help you fix all your issues.
To fix various PC problems, we recommend DriverFix: This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:
  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

If you’re a developer, you might have encountered an Error occurred while trying to proxy request message on your PC.

This error can cause a lot of problems for some users, but today we want to show you a couple of solutions that might help you fix this issue once and for all.

How can I fix Error occurred while trying to proxy request?

1. Check which IP version is the server using

check IP version error occurred while trying to proxy request
  1. Check the IP version of your server.
  2. Make sure that the server and proxy are using the same version of IP.

Users reported this error message because the server was using IPV6 while the proxy used IPV4, but after changing that, the issue was completely resolved.


2. Modify your code

modify code error occurred while trying to proxy request
  1. Open your project.
  2. Now modify the code like this:

{

"/api": {

"target": "https://localhost:12345",

"secure": false,

"changeOrigin": true

}

}

Users reported that adding the changeOrigin setting fixed the problem, so be sure to try that.


3. Change webpack proxy configuration

change webpack configuration error occurred while trying to proxy request
  1. Open webpack.config.js. You should find this file in the root of your project directory.
  2. Make sure that your code looks like this:

devServer: {

  proxy: {

    "*": "http://[::1]:8081"

    // "secure": false,

    // "changeOrigin": true

  }

},

According to users, it’s crucial that you add [::1] in order to fix this problem, so be sure to try that.


4. Modify the hosts file

  1. Open the hosts file. Keep in mind that this file is protected, so be sure to check our guide on how to properly edit hosts file on Windows 10.
  2. Now add the following line to the hosts file:
    127.0.0.1 localhost
    localhost host files error occurred while trying to proxy request
  3. Save changes and check if the problem is resolved.

5. Remove body-parser

remove parser error occurred while trying to proxy request

Many users reported that they fixed this issue simply by removing express body-parser middleware before HPM.

After doing that, the issue was completely resolved, so be sure to try that.


6. Add a header in the client proxy

add a header error occurred while trying to proxy request
  1. Open your code.
  2. Modify it like this:

module.exports = function(app) {

    app.use(proxy('/api', {

        target: 'http://127.0.0.1:8080/',

        headers: {

            "Connection": "keep-alive"

        },

    }));

};

Error occurred while trying to proxy request message can cause a lot of trouble, but hopefully, you should be able to fix it using one of our solutions.

This article covers:
add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *