axios: Request to HTTPS with HTTP proxy fails
Summary
Trying to do a HTTPS request with a HTTP proxy fails.
const req = await axios({
url: 'https://somedomain.com',
proxy: {
host: '89.151.146.7',
port: 6060,
auth: {
username: 'myname',
password: 'mypass',
},
},
});
Results in:
Error: write EPROTO 140736379442112:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794
The problem is already described by @chovy in this ticket, which ended up closed as OP did not have the same problem: https://github.com/mzabriskie/axios/issues/662
@chovy says:
I still have this issue not being able to hit an https url with an http proxy. I can do it fine in request and also in curl from shell. Something not working with axios. I get an EPROTO error.
### Context
- axios version: v0.16.1
- Environment: node v7.10.0, Mac OSX Sierra
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 56
- Comments: 52 (2 by maintainers)
Links to this issue
Commits related to this issue
- fix: https://github.com/axios/axios/issues/925 — committed to stoneChen/axios by stoneChen 7 years ago
- yarn upgrade; import axios@0.19.0-beta1 for https over http proxy support ( https://github.com/axios/axios/issues/925 ) — committed to nanoporetech/epi2me-api by rmp 5 years ago
- Replace request with axios and other updates Updated other deps. Modernized code with async/await. Updated node versions to only include supported versions. Closes #189 — committed to giggio/node-chromedriver by giggio 4 years ago
Had a similar issue recently, my solution was to use an HTTPS-over-HTTP tunnel, specify port 443 explicitly in the URL and disable automatic proxy detection in axios:
More about the solution in this article.
Hope this helps, Jan
Same issue… please merge!
Same issue here
Same issue here: Requesting https resources behind an http proxy.
Result:
Error: getaddrinfo ENOTFOUND http://my.proxy.com http://my.proxy.com:12345
The 0.19.0-beta.1 still does not work. I kept getting
Request failed with status code 400
. Wasted a lot of time on this. Switched to the request library and it worked like a charm on the first try.I’m having the same problem of https request over proxy. I do not want to move to request.js.
Result:
Error: write EPROTO 139800246822688:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794
request.js and curl in this situation works well.
Context
Feel free to use this until they get #959 merged.
@jan-molak My fix is easy to use:
2 years later, still broken!!!
According to the 0.19.0 release, this has been fixed. Since it obviously hasn’t, a new issue should be opened
@jan-molak 's fix saved my day. +1 to merging the PR.
After updating to
0.18.0
this seems to be working for me. I had to specify the following options for my use case though:Here’s what i did for those who stumble upon this and still want to use axios:
This will let you make https requests over an http proxy, simple and neat.
@emilyemorehouse, do you have any estimation when it will be released? The PR #959 solve critical part of the issue, other issues like proxying redirections and so can be improved later. The changes in #959 are pretty simple and can be published in just few minutes.
Any chance to be included in 0.19.0?
This functionality is still broken in axios 0.19. Version 0.19.0 fails with the message “Error: Protocol “http:” not supported. Expected “https:”” Version 0.19.1 fails with “Error: timeout of 1000ms exceeded”. Increasing the timeout doesn’t help. The proxy server expects a
CONNECT
request while axios sends aGET
request.Another +1 to merging this!!
Ran into the same problem.
fixed the problem for me.
@jan-molak’s solution worked for me as well. It would really be nice to not have to force the port number on the url though.
+1 When you fix this? But we need no_proxy too…
Still having the same issue after 2 years.
Is someone working on this or can we join to contribute?
+1 Still using work arounds mentioned above but would love to see this work out of the box.
the PR is here https://github.com/mzabriskie/axios/pull/959
Just ran into this issue myself. Hoping you guys can fix this at some point. czl032405’s solution of using
proxy-agent
worked for me.I can not solve it out in 0.19.0-beta.1, but I fixed like this
Me and a colleague of mine identified the problem, a PR should be coming soon