When I run locally always get 403 Forbidden

I just installed libretranslate with python3 on a mac, after that I run the lib without arguments, I try to exec any http method and always get 403 Forbidden, please help!

1 Like

Aside from 403, do you get an error message on the response body?

Hi, no, the response is empty

Mm, I’m not sure what would cause the error.

Hi,
I am facing something similar. I have been sent a frontend coding challenge that requires me to consume the LibreTranslate API. I was instructed to use the libretranslate.com version and not a local setup. However, when I send the request from my frontend code using axios, I get a 403 response with the body:

{
“error”: “Please contact the server operator to obtain an API key”
}

The above happens even though api_key is indicated as not required in the docs. Please advise me on:
a) How to contact admin to get an API key or
b) How to send a request without setting api_key in the request body

Thanks

The API on libretranslate.com requires an API key.

Installing the software on your machine from https://github.com/LibreTranslate/LibreTranslate does not require an API key.

You can purchase a key by visiting Stripe Checkout

2 Likes

Amazing! Thanks a lot for being very clear and giving the exact steps to take.

1 Like

I have the same problem as haroldsanchezb.

I also have a Mac (Ventura 13.1, 2019) and always get the 403 Forbidden response. I tried installing libretranslate locally and also using the docker (all versions down to 1.3.0). Here is the response (from the docker instance):

Response {
  [Symbol(realm)]: null,
  [Symbol(state)]: {
    aborted: false,
    rangeRequested: false,
    timingAllowPassed: true,
    requestIncludesCredentials: true,
    type: 'default',
    status: 403,
    timingInfo: {
      startTime: 76.13303700089455,
      redirectStartTime: 0,
      redirectEndTime: 0,
      postRedirectStartTime: 76.13303700089455,
      finalServiceWorkerStartTime: 0,
      finalNetworkResponseStartTime: 0,
      finalNetworkRequestStartTime: 0,
      endTime: 0,
      encodedBodySize: 0,
      decodedBodySize: 0,
      finalConnectionTimingInfo: null
    },
    cacheState: '',
    statusText: 'Forbidden',
    headersList: HeadersList {
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    urlList: [ [URL] ],
    body: { stream: undefined }
  },
  [Symbol(headers)]: HeadersList {
    [Symbol(headers map)]: Map(2) { 'content-length' => '0', 'server' => 'AirTunes/670.6.2' },
    [Symbol(headers map sorted)]: null
  }
}

I am grateful for any help

1 Like

Try changing port? It looks like you’re getting a response from “AirTunes” which is most definitely not a reply from LibreTranslate.

@haroldsanchezb same issue here on Windows.

Have you managed to solve it?

I’ve created github issue for it

1 Like

On a mac AirTunes is already using port 5000. You need to change the port that Libretranslate is using locally. ie If you are running it via docker compose, in docker-compose.yml change ports: “5000:5000” to “5001:5000”. Then you can visit the app on http://localhost:5001

2 Likes