Code Monkey home page Code Monkey logo

Comments (5)

laurentS avatar laurentS commented on June 8, 2024

Hi @juanretamales I suspect this is a problem with your code, where File "/home/ubuntu/proyect/api/env/lib/python3.10/site-packages/slowapi/util.py", line 21, in get_remote_address Oct 25 20:16:46 gunicorn[12540]: return request.client.host or "127.0.0.1" Oct 25 20:16:46 gunicorn[12540]: AttributeError: 'NoneType' object has no attribute 'host' is the key point:

request.client is None in your execution, I don't think this has anything to do with slowapi.

from slowapi.

juanretamales avatar juanretamales commented on June 8, 2024

i search and the problem is when you use gunicorn (here has the problem), i suggest any method or option for skip the error when appears.

from slowapi.

thentgesMindee avatar thentgesMindee commented on June 8, 2024

Hi @juanretamales
If I'm not wrong, this error happens when your application is running behind a proxy such as nginx (maybe gunicorn as well).
You should make sure you correctly proxy the headers at the proxy level.

from slowapi.

thentgesMindee avatar thentgesMindee commented on June 8, 2024

Here is an example configuration that should do the trick, if you use nginx

proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

EDIT: also with this, for security reason you should add some middleware (for example this one from starlette) to avoid your clients forging their host/ip

from slowapi.

laurentS avatar laurentS commented on June 8, 2024

@juanretamales did the comment above help? if so can you close this issue?

from slowapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.