Connection Timeout

Limit how long to wait for connection

cURL Command

curl --connect-timeout 5 --max-time 30 https://api.example.com/slow

Flag-by-flag explanation

--connect-timeout 5
Max seconds to establish connection
--max-time 30
Max total time for entire operation

Python equivalent

import requests
r = requests.get("https://api.example.com/slow", timeout=(5, 30))

JavaScript fetch equivalent

const ctrl = new AbortController();
setTimeout(() => ctrl.abort(), 30000);
await fetch(url, { signal: ctrl.signal });

Related cURL examples

Tools

cURL Generator →