Curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused

Here is the section in my Jenkinsfile:

stage(‘Start container’) {
steps {
sh ‘docker compose up -d --no-color --wait’
sh ‘docker compose ps’
}
}
stage(‘Run tests against the container’) {
steps {
sh ‘curl http://127.0.0.1:3000/param?query=demo | jq’
}
}

In the test stage above, I got the error below:

  • curl http://127.0.0.1:3000/param?query=demo

  • jq
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed

    0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
    0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
    curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused.

Could anyone please help me resolve the issue? Thanks much.