question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: ECONNREFUSED: Connection refused in Gitlab CI

See original GitHub issue

Hi

Running my tests through GItlab CI returns the following error Error: ECONNREFUSED: Connection, but they all pass and work fine locally.

Please see my stackoverflow for more details thread

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
jonathansaminescommented, Aug 15, 2018

@KayHS I hope the information below still is helpful.

Given the way you are initializing supertest (you are providing an http server instance), it will try to get the port information from the server instance. However the “hostname” information where the server was bound to, is determined by the supertest instance construction and fallbacks to 127.0.0.1 when it is not provided.

See:

  1. Test is created without the host argument: https://github.com/visionmedia/supertest/blob/master/index.js#L25

  2. Given that a server object was provided, the server address is computed: https://github.com/visionmedia/supertest/blob/master/lib/test.js#L36

  3. Since no host was provided, it fallbacks to 127.0.0.1 https://github.com/visionmedia/supertest/blob/master/lib/test.js#L62

And that is what I think is happening. When you are in your local machine your test is probably binding to localhost, however in your CI seems like it is bounding it to a different host, but since supertest is not aware of that it is still trying to reach 127.0.0.1:

Server Running On: runner-sefsf-project-41-concurrent-0gdrs7:3000

The solution in this case, is to either force your test server to be always bound to 127.0.0.1 or to use the request('http://my-domain.com:port') to construct supertest in a way that the server information gets ignored.

1reaction
colibiecommented, Dec 22, 2018

I have this error too, even after binding using request('http://localhost:5555'); . I still get CONNECTION REFUSED error on travisCI

Read more comments on GitHub >

github_iconTop Results From Across the Web

CI/CD: Error: ECONNREFUSED: Connection refused - GitLab
I have a nodejs, express api built using typescript and a mongo database. I am using mocha, chai and supertest to write my...
Read more >
Error: ECONNREFUSED: Connection refused in Gitlab CI #488
Hi Running my tests through GItlab CI returns the following error Error: ECONNREFUSED: Connection, but they all pass and work fine locally.
Read more >
GitLab CI with Postgres ERROR: connect ECONNREFUSED ...
So according to your error message I assume your code tries to reach the postgres database on localhost which works when you run...
Read more >
connect ECONNREFUSED 127.0.0.1:5432 on Gitlab CI-docker
It seems like your npm command does not use the POSTGRES_HOST in variables section. Instead it uses 127.0.0.1 when connecting to postgres and...
Read more >
Failed to connect to 127.0.0.1 port 80 - Super User
For a while already you need to use https for this to work, so setup your gitlab environment with ssl certificate.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found