Basic Digest Authentication request not working

Followed examples given in HTTP Authentication and we are getting error: ERRO[0000] GoError: parse “”: invalid port “:testing” after host
at (native)

We have user id:, password: testing123 (sample data) and BASEURL:

How to implement basic digest authentication?

Hi @huligesh.hanumanthap,
Are you saying that you have @ in the username? In that case you will need to encode it as @ is a special character, you can use encodeURIComponent as in

var username = ...;
var password = ...;
var url = "https://"+encodeURIComponent(username) + ":" + encodeURIComponent(password) + "@hostname.domain/path";

Hope this helps

1 Like

Instead of, the URL should be The URL syntax is scheme://username:password@host:port/path, see URL - Wikipedia

Hi @mstoykov,
Thanks for your time.

I tried below code and it is failing with 401-Unauthorized error:

var username = '';
var password = 'testing123';
var url = "https://"+encodeURIComponent(username) + ":" + encodeURIComponent(password) + "";
let res = http.get(url);

Error: HTTP 401 - Unauthorized.

But credential passed are correct and working fine manually.


I recommend

  1. printing the url to console
  2. checking with curl that you can make the request from the machine you are running k6 from
  3. using --http-debug to see what is actually being send.

This should provide you with some leads on what to do next.

@huligesh.hanumanthap, since you mention digest authentication in the title, I’m guessing the HTTP call should be like this:

let res = http.get(url, {auth: 'digest'});

See Params

1 Like

Hi @mstoykov and @ned ,
Thanks for you time!

As suggested, We tried using curl and getting expected HTTP 200 OK response.
curl -v -u

But, when we try in k6 as below, we are getting 401 Un-authorized error. k6 retires 3 times and throws 401 Unauthorized error.

var username =;
var password = testing123;
var url = "https://"+encodeURIComponent(username) + ":" + encodeURIComponent(password) + “";
let response = http.get(url, {auth: 'ntlm'});

It retries 3 times and throws 401 Unauthorized error as below:

Any suggestions would be help full here!