# Requests returning a 404 error constantly

**URL:** <https://discuss.huggingface.co/t/requests-returning-a-404-error-constantly/155450>\
**Category:** Beginners\
**Created:** [May 16, 2025, 2:21am UTC](https://discuss.huggingface.co/t/requests-returning-a-404-error-constantly/155450 "2025-05-16T02:21:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacafourtwenty](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jacafourtwenty/32/47621_2.png) [@jacafourtwenty](https://discuss.huggingface.co/u/jacafourtwenty)\
**Post date:** [May 16, 2025, 2:21am UTC](https://discuss.huggingface.co/t/requests-returning-a-404-error-constantly/155450/1 "2025-05-16T02:21:20Z")

</div>

Been trying to make a successful request but everything I try returns a 404 error.

Any advice is appreciated.

```auto
router.get("/test-huggingface-debug", async (req, res) => {
  try {
    // Get API key
    const hugKey = [apiKeyHere];
    if (!hugKey) {
      return res.status(500).json({
        success: false,
        error: "Hugging Face API key not configured",
      });
    }

    console.log(`API Key loaded, starting with: ${hugKey.substring(0, 3)}..., length: ${hugKey.length}`);

    // Use the simplest, most reliable API format with a guaranteed available model
    console.log("Attempting direct API call with fetch...");
    
    // Build the URL and options manually
    const url = "https://api-inference.huggingface.co/models/gpt2";
    const options = {
      method: "POST",
      headers: {
        Authorization: `Bearer ${hugKey}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ inputs: "Hello, I am testing the Hugging Face API." })
    };
    
    // Use native fetch API instead of axios
    console.log("Sending request to:", url);
    const response = await fetch(url, options);
    console.log("Response status:", response.status);
    
    if (!response.ok) {
      const errorText = await response.text();
      console.error("Error response body:", errorText);
      throw new Error(`API responded with status ${response.status}: ${errorText}`);
    }
    
    const data = await response.json();
    console.log("Success! HF Response:", JSON.stringify(data).substring(0, 200));

    return res.status(200).json({
      success: true,
      message: "Successfully connected to Hugging Face API",
      data: data
    });
  } catch (error) {
    console.error("Test HF error:", error.message);
    
    return res.status(500).json({
      success: false,
      error: `Failed to connect to Hugging Face: ${error.message}`
    });
  }
});

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [May 16, 2025, 6:31am UTC](https://discuss.huggingface.co/t/requests-returning-a-404-error-constantly/155450/2 "2025-05-16T06:31:33Z")

</div>

It seems that the specifications have changed and it no longer works.

> [@Persistent 404 Not Found Errors with Public Inference API](https://discuss.huggingface.co/t/persistent-404-not-found-errors-with-public-inference-api/154119):
>
> Problem: For the past day or so, all My attempts to make POST requests to the public Inference API endpoint result in a 404 Not Found error. This happens regardless of the model I try to query, including standard, known-available models like gpt2. The response body simply contains “Not Found"“ My Hugging Face Username: Mehdimemar Troubleshooting Steps Taken: Model Validity Confirmed: I’ve tested numerous valid model IDs (like gpt2, distilbert-base-uncased-fine tuned-sst-2-english, various …

> [@https://api-inference.huggingface.co/models/sentence-transformers/paraphrase-MiniLM-L6-v2](https://discuss.huggingface.co/t/https-api-inference-huggingface-co-models-sentence-transformers-paraphrase-minilm-l6-v2/153574):
>
> Hello All, I am using sentence-transformers/paraphrase-MiniLM-L6-v2 while using the API. but getting the 404 error. We are in free plan. any help please

---

<div class="post-metadata">

**Author:** ![jacafourtwenty](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jacafourtwenty/32/47621_2.png) [@jacafourtwenty](https://discuss.huggingface.co/u/jacafourtwenty)\
**Post date:** [May 16, 2025, 4:25pm UTC](https://discuss.huggingface.co/t/requests-returning-a-404-error-constantly/155450/3 "2025-05-16T16:25:25Z")

</div>

It started working today. so it must have. been a temporary thing

thanks for replying
