Testing a custom port on a web server

This question may have a very simple answer but I was wondering I can run my k6 GET tests against a server API on:

  • AA.BB.CC.DD:8443
  • AA.BB.CC.DD:8080

Thanks,

You should be able to add the port number to the URL. Here’s a sample script that hits a local server on a custom port:

import { check } from 'k6'
import http from "k6/http";

export default function() {
  const res = http.get('http://localhost:8090/test')
  check(res, {
    'status is 200': (r) => r.status === 200,
    'latency is under 500ms': (r) => r.timings.duration <= 500,
  })
}
2 Likes