Connect ECONNREFUSED when trying to test my API with Postman(Newman)

Hello, I’m testing a REST Java API using Postman and its command line tool Newman. Everything works fine when launching the tests from the command line. Now I’d like to integrate Newman to Travis and have Travis launch the tests during the build.

The problem is that the connection to localhost:8080 (where my API is supposed to be) is refused (see picture below)

Here is my travis config file :

language: java

jdk: openjdk8

    - $HOME/.m2


  - cd p12-api
  - npm install newman

  - postgresql

  - node --version
  - npm --version
  - pwd
  - node_modules/.bin/newman --version
  - psql -c 'create database p12_demo;' -U postgres

  - mvn clean install -Pintegration-test
  - node_modules/.bin/newman run Tests_Postman/P12_Travis.postman_collection.json

  - bash <(curl -s

What am I doing wrong? Any clues appreciated.

The first obvious question is: Is your server running and listening to port 8080?

Yes, it is. As I wrote, all works fine when I start the tests directly from the command line instead of throug Travis:

I didn’t ask if it works on your machine. Is the server running and listening to the port when the test execution gets to that point?

When reporting problems, please include relevant build URLs. Thanks.

Sorry for the newbie question, but how can I obtain the build URL? I found a github discussion where you mentioned the env variables TRAVIS_JOB_WEB_URL and TRAVIS_BUILD_WEB_URL` . Should I basically set these variables in my .travis.yml file with random values? How can I then deduce the url?

Go to your browser’s address bar, and copy the URL.

My repo on git was private, that’s why it didn’t work. I made it public, here the build url:

This is what I did:

  • start the API on port 8080 from my IDE
  • commit and push of my project > that triggers the build on Travis
  • in my .travis.yml file, I have 2 scripts: one for launching the integration tests (use of port 8089), one to launch the tests I designed on Postman (request to API on localhost:8080)

I’m wondering: is my problem due to the fact that I haven’t started my API in Travis ?
Thanks for your help.

In this configuration

Which part is responsible for starting the API server on port8080?

I see various commands to show software versions, database setup and mvn clean install. Unless node_modules/.bin/newman run starts up the server (which seems logically wrong), I don’t see how anything would be listening to port 8080.

I don’t think you gave us any URL until now.

Coincidentally, I can read the logs (for support reasons such as this), so if you want to put this back to private, you can.

Thanks for your time. You’re right: nothing in the config is responsible for starting the API on port 8080.
So far i started the server manually from my IDE.
I guess what I could try next is add a script in the config to start the API (a spring boot project) on 8080.