# How to increase timeout in k6(my api takes more than 1.5 mins to respond)

**URL:** <https://community.grafana.com/t/how-to-increase-timeout-in-k6-my-api-takes-more-than-1-5-mins-to-respond/98279>\
**Category:** Grafana k6\
**Created:** [July 6, 2021, 12:57pm UTC](https://community.grafana.com/t/how-to-increase-timeout-in-k6-my-api-takes-more-than-1-5-mins-to-respond/98279 "2021-07-06T12:57:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prateekhasher](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/prateekhasher/32/35517_2.png) [@prateekhasher](https://community.grafana.com/u/prateekhasher)\
**Post date:** [July 6, 2021, 12:57pm UTC](https://community.grafana.com/t/how-to-increase-timeout-in-k6-my-api-takes-more-than-1-5-mins-to-respond/98279/1 "2021-07-06T12:57:21Z")

</div>

How to increase timeout in k6(my api takes more than 1.5 mins to respond)  
i tried to google it but not getting any proper resolutions  
Where can i make the change in my code?

Please help me for this issue

---

<div class="post-metadata">

**Author:** ![dan\_nm](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dan\_nm](https://community.grafana.com/u/dan_nm)\
**Post date:** [July 6, 2021, 9:56pm UTC](https://community.grafana.com/t/how-to-increase-timeout-in-k6-my-api-takes-more-than-1-5-mins-to-respond/98279/2 "2021-07-06T21:56:23Z")

</div>

A timeout value can be set as part of the params object for an HTTP request if you need to override the default value of 60s. The value supplied can either be a string, or a numeric value (the numeric value would be interpreted as milliseconds). Not sure whether or not k6 supports setting this test-wide.

> **[Params](https://k6.io/docs/javascript-api/k6-http/params/)**
>
> Used for setting various HTTP request-specific parameters such as headers, cookies, etc.

Example:

```auto
let params = {
  timeout: '120s'
};

let res = http.get('https://k6.io', params);

```

---

<div class="post-metadata">

**Author:** ![rdt.one](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/rdt.one/32/36067_2.png) [@rdt.one](https://community.grafana.com/u/rdt.one)\
**Post date:** [September 13, 2024, 3:21pm UTC](https://community.grafana.com/t/how-to-increase-timeout-in-k6-my-api-takes-more-than-1-5-mins-to-respond/98279/3 "2024-09-13T15:21:10Z")

</div>

> [@dan\_nm](#):
>
> Not sure whether or not k6 supports setting this test-wide.

Probably a bit late to reply, but here is an example on how to set it test-wide by using the Httpx js lib

```auto
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js';

const session = new Httpx({
  baseURL: 'https://test-api.k6.io',
  headers: {
    'User-Agent': 'My custom user agent',
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  timeout: 20000, // 20s timeout.
});

```

More info at [httpx | Grafana k6 documentation](https://grafana.com/docs/k6/latest/javascript-api/jslib/httpx/#example)
