# Getting net::ERR\_CONNECTION\_REFUSED at http://172.19.0.3:3001/ error when trying to run tests against localhost

**URL:** <https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314>\
**Category:** Running Tests\
**Tags:** nodejs\
**Created:** [September 7, 2022, 2:41am UTC](https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314 "2022-09-07T02:41:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexkyrylenkoproven](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/alexkyrylenkoproven/32/31019_2.png) [@alexkyrylenkoproven](https://discuss.circleci.com/u/alexkyrylenkoproven)\
**Post date:** [September 7, 2022, 2:41am UTC](https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314/1 "2022-09-07T02:41:22Z")

</div>

HI all, I am getting this error when running my tests against the local host-net::ERR\_CONNECTION\_REFUSED at [http://172.19.0.3:3001/](http://172.19.0.3:3001/) error when trying to run tests against localhost  
I can see that the server is started based on this output in the previous to running the tests step  
Connecting to 172.19.0.3:3001… connected.  
HTTP request sent, awaiting response… 200 OK  
But then I get this error when trying to run my tests against the localhost net::ERR\_CONNECTION\_REFUSED at [http://172.19.0.3:3001/](http://172.19.0.3:3001/)  
Also, I am not using docker  
Any idea why is this happening?

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [September 7, 2022, 9:18pm UTC](https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314/2 "2022-09-07T21:18:32Z")

</div>

Hi @alexkyrylenkoproven ,

Although I’m not sure at all if it’s related to the issue you’re having, I noticed a slight difference.

You mention that the previous step before running the tests says:

`Connecting to 172.19.0.3:3002... connected`

&nbsp;  
However, the error you’re getting references another port:

`net::ERR_CONNECTION_REFUSED at http://172.19.0.3:3001/`

&nbsp;  
Could this be a misconfiguration of your tests?

---

<div class="post-metadata">

**Author:** ![alexkyrylenkoproven](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/alexkyrylenkoproven/32/31019_2.png) [@alexkyrylenkoproven](https://discuss.circleci.com/u/alexkyrylenkoproven)\
**Post date:** [September 7, 2022, 10:26pm UTC](https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314/3 "2022-09-07T22:26:21Z")

</div>

thank you @yannCI - you were correct I was trying to call on a wrong port. However, after switching to the correct port, I am still getting this error - net::ERR\_CONNECTION\_REFUSED at [http://192.168.192.3:3002](http://192.168.192.3:3002)  
this is the part of the yml file that starts the server and runs the tests:  
steps:

```
    - install-deps:
        after-install-deps:
          - run:
              name: starting node server
              command: mkdir logs && npm run start | tee logs/node_server.log
              background: true
          - run:
              name: storing local IP address
              command: node -p "require('ip').address()" > logs/ip.log
          - run:
              name: waiting for node server to start
              command: wget --retry-connrefused --waitretry=2 -t 5 "http://$(cat logs/ip.log):3002" > /dev/null
          
          - run: npx playwright install --with-deps
          - run: npm run test:ui:ci
    - store_artifacts:
        path: ./playwright-report
        destination: artifacts

```

And then, the base url is set like baseURL: `http://${require('ip').address()}:3002`

Blockquote

---

<div class="post-metadata">

**Author:** ![daluu](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/daluu/32/10746_2.png) [@daluu](https://discuss.circleci.com/u/daluu)\
**Post date:** [July 3, 2025, 6:32am UTC](https://discuss.circleci.com/t/getting-net-err-connection-refused-at-http-172-19-0-3-3001-error-when-trying-to-run-tests-against-localhost/45314/4 "2025-07-03T06:32:52Z")

</div>

Was this resolved? If so, how?
