Error: Could not proxy request: TypeError: fetch failed
I recently upgraded to wrangler 2.12.0 and started getting
[pages:err] Error: Could not proxy request: TypeError: fetch failed
error all of a sudden. I thought this is an issue with the new version and so downgraded to the version (2.9.1) which I was using earlier but issue still persists. Changed the port of vite dev server to make sure that the port number is not in use already but issue still remains. What could be the reason behind this issue?24 Replies
Updated to 2.12.1 but still same error. Any idea why this is happening?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I was facing this issue with a vuejs application containing pages functions and so I tried it with another application without any function which does not have fetch anywhere in the code and it is still throwing same error. How can I enable detailed logging to see what is going wrong?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
no that is not the case. I am using
wrangler pages dev --port 8888 -- yarn preview
command to run the vite preview server which starts the server and I can see it in the console.
I am able to access the application directly after executing above command.Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
No. but it is able to detect the correct port automatically.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes
One reason could be that vite preview server is listening on localhost instead of 127.0.0.1.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Because of command alias in package.json file -
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
This application proxies request to another application running on port 8091 which was not working with localhost. It started working after changing localhost to 127.0.0.1.
I have a feeling that wrangler is failing due to same issue.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
let me try
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Mine is a windows machine and it does not have nc command installed.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I spinned up a simple nodejs application which is working fine directly as well as through wrangler.
So it seems to be an issue with the vite preview server which is listening on localhost instead of 127.0.0.1.
Is there any way to specify proxy host in wrangler?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
did that and still same error.
I don't think it is going to work unless vite preview server listens on 127.0.0.1 or there is a way in wrangler to specify proxy host.
Even though I am starting vite preview server with
--host 0.0.0.0
flag, it is not listening on 127.0.0.1 unlike wrangler dev server which is listening on all the IPs.
Host name is hardcoded in wrangler and so it seems we can't specify hostname -
Anyway thanks for all your help.Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
sorry didn't get you. what you mean by own server?
Reported this issue in wrangler cli repo - https://github.com/cloudflare/workers-sdk/issues/2872
GitHub
🐛 BUG: Wrangler is using localhost instead of 127.0.0.1 to proxy re...
Which Cloudflare product(s) does this pertain to? Wrangler What version of Wrangler are you using? 2.12.1 What operating system are you using? Windows Describe the Bug I am using wrangler to proxy ...