Replies: 29 comments 30 replies
-
Have you added logging to the |
Beta Was this translation helpful? Give feedback.
-
No, but that is a great idea for a next step. I will update when I know more. |
Beta Was this translation helpful? Give feedback.
-
@marlboro if you posted your question elsewhere, could you link it? I'm having similar issues. |
Beta Was this translation helpful? Give feedback.
-
@Helveg No, but it's a bug or configuration issue with either PHP or Laravel. Originally this particular API was only called by one device and there were no issues. We added a second device and suddenly the 429's started. I would have expected each device (unique IP's) to get N requests before they got throttled. That is not the case or I would not be having issues. I ended up just increasing the throttle value large enough to make it stop issuing 429's. It's hacky, and I hate it, but I had no other choice. Post a link if you get help somewhere else. |
Beta Was this translation helpful? Give feedback.
-
I got the same issue, my throttle was set to 270, and it is still happening, I believe it should be an issue with laravel, because there is no way for me to have 270 calls to my api from one device of testing in 1 minute |
Beta Was this translation helpful? Give feedback.
-
I'm currently converting my web app UI to an SPA and running into the same issue. I get the error sporadically when I'm sure I'm nowhere near the limit. |
Beta Was this translation helpful? Give feedback.
-
Just posting this if anyone else was getting the same error. I was using Memcached as my cache store and after debugging through telnet, I found that it was never expiring my keys. I had to manually restart the service to fix the problem. Homestead with memcached version 1.5.6. |
Beta Was this translation helpful? Give feedback.
-
Did anyone find out the problem? We're facing same issues here. |
Beta Was this translation helpful? Give feedback.
-
Same issue. Laravel 5.7, IIS10, PHP 7.3. |
Beta Was this translation helpful? Give feedback.
-
It's a sporadic recurring issue, all or most of us reporting the issue face it in controlled testing environments as well where we're sure to be nowhere near the limit. @driesvints can we get some feedback, troubleshooting tips or a timeline on this? Is there maybe a way that we can log every time a supposed request gets us closer to the throttle limit to debug it? |
Beta Was this translation helpful? Give feedback.
-
Also a firefighting tip: you can clear the throttle if it hits your production environment with:
|
Beta Was this translation helpful? Give feedback.
-
@Helveg Yes, logging can be done on the client. Look in the headers of the response. It should look something like this: DK@DK:~$ curl -I -X POST http://localhost/fake/path
HTTP/1.1 400 Bad Request
Date: Tue, 01 Oct 2019 20:29:45 GMT
Server: Apache/2.4.39 (Fedora) OpenSSL/1.1.1b
X-Powered-By: PHP/7.2.19
Cache-Control: no-cache, private
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json You're looking for The issue I was having was in the Kernel. Inside of /* ... */
protected $middlewareGroups = [
'web' => [
/* .. */
],
'throttle' => ['throttle:99,1'], //No idea why, but this works!
'api' => [
'throttle:5000,1', //These values did not change the throttle limit.
'bindings',
],
];
/* ... */ I found this by adding some dump()'s here: https://github.com/laravel/framework/blob/5.7/src/Illuminate/Routing/MiddlewareNameResolver.php#L29 |
Beta Was this translation helpful? Give feedback.
-
worked thanks |
Beta Was this translation helpful? Give feedback.
-
I had to remove the throttling from the
|
Beta Was this translation helpful? Give feedback.
-
That's not very good advice: the throttle is there for good reasons. You're now vulnerable to being spammed with requests such as login requests. Never advice to completely disable security measures even if they aren't functioning properly |
Beta Was this translation helpful? Give feedback.
-
I do agree that any good system architecture should incorporate the necessary security measures. However, these measures should be supplemented with a good understanding of the internals. My response was in the context of the specific OP query assuming they know what they are doing, and not a general system architecture advice. Also, most apps would use the Your thoughts are absolutely valid and I appreciate you providing the helpful perspective here. I just wanted to make sure that people who find the solution helpful would know what they are working with. Cheers! |
Beta Was this translation helpful? Give feedback.
-
how to increase request limit in laravel. |
Beta Was this translation helpful? Give feedback.
-
FWIW - I was causing this issue with the "infinite loop" situation with useEffect() in React. I added the empty array to stop triggering repeated requests. |
Beta Was this translation helpful? Give feedback.
-
i do not recommend removing throttling, it's a huge security risk,like DOD and DDOS attacks |
Beta Was this translation helpful? Give feedback.
-
Hello, I tried to comment It worked for me. Sorry for the typo |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, so, is there a proper way to fix this issue without disabling throttle if I'm using Sanctum for my API authentication and Fortify for my web authentication? |
Beta Was this translation helpful? Give feedback.
-
My guess is that you're using a login proxy to passport so server is requesting tokens rather than the user. You should disable the throttling specifically for localhost (ips from server). |
Beta Was this translation helpful? Give feedback.
-
Am using Laravel 8 for my API and I have a couple of clients accessing my API. Recently I started to get 429 HTTP response after I added some new clients. What I found out is that, by default rate limit is not IP specific, so when I added more clients (each client has its own IP) I started to get 429. I modified rate limit to use IP and this solved the issue for me. This is how I did that.
More information on how to do this with Laravel 8 can be found here. And also there is a nice explanation about it in Laracasts. It is also possible to set up rate limiting per route, (for example api/images) instead of a route group like api/. Also to keep in mind is that this is Laravel 8 way of rate limiting. For versions below 8, rate limiting is done differently. But I assume it is possible to rate limit per IP and per route in versions below 8. Also I think, in general, it is worthwhile to try out IP specific and/or route specific rate limit instead of removing rate limit completely or increasing rate limit to a very high value. |
Beta Was this translation helpful? Give feedback.
-
In laravel version above 7.x |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I experiences this because it was IP address driven and perhaps the users internet provider reused the IP addresses of their customers making anonymous users appears to be the same person, hitting too many times. Has anyone else experienced this? I want to suggest it might be cloudflare related but I think the code accounts for the use of cloudflare's request headers. |
Beta Was this translation helpful? Give feedback.
-
@marlboro were you able to resolve this issue? If so, how? |
Beta Was this translation helpful? Give feedback.
-
`use Illuminate\Cache\RateLimiting\Limit; /**
|
Beta Was this translation helpful? Give feedback.
-
@marlboro I have experienced this kind of issue and made me panic. My solution is to change the CACHE_DRIVER to array in your .env file. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have been trying for the better part of a week to diagnose why my Laravel 5.7 based API has suddenly started having issues with throttling (429: Too Many Requests). I have (for years) logged every request via a custom middleware and I don't see nearly enough requests to constitute any throttling. To confirm this I have run Wireshark on both the affected client and the web server during the affected periods. This confirmed that maybe 20 requests happened before my service started responding with the 429: Too Many Requests. I'm lost as to how to proceed with troubleshooting.
Environment:
IIS 10, PHP 7.1.26, Laravel 5.7.25.
Kernel.php
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions