Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ismailkriam's avatar

Prevent curl

i need to prevent any curl request to my site. can any one help me to find method to prevent it.

0 likes
2 replies
desjob's avatar

The short answer is, i don't think it's possible.

Curl is basically just an HTTP client, just like a browser. It can send HTTP requests to a given URL, and show the response body (the HTML) as raw text. What you're asking is similar to saying, "can i prevent people using Firefox from sending requests to my site?"

I guess you could check the User agent header (https://en.wikipedia.org/wiki/User_agent) and do something different when it's a request coming from curl.

I hope this was helpful.

Why do you want to block curl requests?

1 like
bikerboy's avatar

@desjob is right.

If the request comes from a single IP then you can block it using IPTABLES (assuming you are running on linux). Other option as mentioned above is to block requests based on the user agent if that's unique.

If you have a public API and people are sending CURL requests, then the easiest way is to put it behind an authentication method, or only allow it from certain IP addresses.

Please or to participate in this conversation.