Skip to content

400 Bad Request with Proxy #5256

Closed
Closed

Description

Describe the bug

https://stackoverflow.com/questions/60578209/axios-proxy-configuration-causing-bad-request

Similar questions have been asked in the past on Stackoverflow and others, but there is a Proxy that is similar and still doesn't work.
I have seen that it works correctly without other Proxies or Proxies, but with certain Proxies something in the request is missing or corrupted and I have seen that a 400 Bad Request is returned from the server.

We have also confirmed that the problem is not a Proxy.
We have seen successful requests in Python's requests module, etc.

To Reproduce

This only happens with some Proxies, which are difficult to reproduce because they require purchase.
So I can send logs instead.

Code snippet

const response = await axios.get('https://twitter.com/', {
    proxy: {
        protocol: 'http:',
        hostname: 'rotating.world.h1.ghostealth.com',
        port: 2137
    }
})

Expected behavior

No response

Axios Version

1.1.3

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

18.12.1

OS

Windows 11

Additional Library Versions

No response

Additional context/Screenshots

No response

Activity

  1. Safari77 commented on Mar 4, 2023

    @Safari77

    Something in Microsoft Code is doing (squid log):
    1677924294.688 103/ 102 127.0.0.1:42116 TCP_DENIED/403 3960 GET - https://api.adoptium.net/v3/info/available_releases 1.1 - HIER_NONE/- text/html "axios/0.21.4"

    It should do:
    CONNECT api.adoptium.net:443 HTTP/1.1
    and wait for
    HTTP/1.1 200 Connection established

    For more details, see RFC 7230.
    Originally specified in RFC 2817 (published on May 2000).

  2. paulhybryant commented on Apr 28, 2023

    @paulhybryant

    I am getting this error still

  3. fantik11 commented on May 15, 2023

    @fantik11

    Having this error too

  4. binitgutka commented on May 18, 2023

    @binitgutka

    I am also getting the same error.

  5. Baatezus commented on Aug 31, 2023

    @Baatezus

    I am also getting the same error.

  6. livingflore commented on Sep 28, 2023

    @livingflore

    +1

  7. m4heshd commented on Feb 19, 2024

    @m4heshd

    Why is this issue being ignored? Wasted about 3 hours of my day. 🫤

  8. terion-labs commented on Apr 17, 2024

    @terion-labs

    Getting this on Node environment, while in Bun — proxy works

  9. rriemann commented on Sep 19, 2024

    @rriemann

    That's my workaround.

      const { HttpsProxyAgent } = require('https-proxy-agent');
      const httpsProxyAgent = new HttpsProxyAgent(process.env.https_proxy)
    
      axios.get(url_https, {proxy: false, httpsAgent: httpsProxyAgent})

    Please fix this soon. It took me quite some time to track down this issue.

  10. oakh1 commented on Feb 18, 2025

    @oakh1

    Is there some fix for this? I am getting the same error and when checking using a TCPdump towards the proxy itself I can see that Axios skips sending the CONNECT request, which of course will make the Proxy send 400 as it expects to receive a CONNECT request before the actual GET request.

  11. self-assigned this
    on Aug 1, 2025
  12. AdrianoLMRS commented on Aug 11, 2025

    @AdrianoLMRS

    same issue here...

  13. added
    issue::bug
    on Mar 29, 2026
  14. jasonsaayman commented on Apr 24, 2026

    @jasonsaayman
    Member

    Closing due to age and lack of reproduction. A 400 returned through a proxy is almost always the proxy or upstream rejecting the request shape (missing Host header, CONNECT vs absolute-URI form, proxy auth). Compare the on-the-wire request against one made with curl through the same proxy.

    If you can still reproduce on a current axios version with a minimal case, please open an issue and tag me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

issue::bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions