Questions tagged [econnrefused]

This tag is for you when you get ECONNREFUSED errors trying to connect to a server with http, https, tcp, or any other tcp-based protocol this. Please show the URL or hostname, and always include the port number in your question. If you're trying to connect to a service (redis, postgreSQL ...) show the service.

What is this?

ECONNREFUSED is an error from your operating system's TCP communication software. HTTP, HTTPS, WS, WSS, email, databases, and many other communications protocols use TCP.

It usually comes back promptly. Another similar error, , comes back after 30-60 seconds.

It means that your request to connect reached the host machine but found no server software running on the port you requested. When no server software is running, the host machine sends back ECONNREFUSED.

For example:

  • Your program please connect to MySQL on dbms.example.com port 3306.

  • Your OS hey, dbms.example.com, I want a TCP connection to your port 3306.

  • Host OS hmm, nothing here is running on port 3306. I must reply with an ECONNREFUSED message.

  • Your OS hey, program, I just got ECONNREFUSED. No connection for you!

  • Your program gets back the error and handles it however your programming environment handles errors.

  • You time to hit https://stackoverflow.com/questions/tagged/econnrefused

What's in the documentation?

The documentation for UNIX-heritage operating systems (MacOS, Linux, FreeBSD) says this about it.

ECONNREFUSED A connect() on a stream socket found no one listening on the remote address.

The Windows documentation says this:

WSAECONNREFUSED 10061 Connection refused No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.

What to do?

If you're trying to connect to a service like MySQL, postgreSQL, redis, a webservice, or similar services, it means the service you want is not running on the machine you mentioned at the port you mentioned. If you didn't mention a port, it means the service is not running on its default port. Fix: run the service on the machine, or connect to the machine that actually has the service.

If you are trying to use a service you developed yourself, it means you forgot to run the service before you tried to connect to it. Fix: run your service.

Specific troubleshooting steps

  • You already know you can reach the host machine you're connecting to, because ECONNREFUSED occurs when it actively refuses your request to connect. If the host machine is switched off or behind a firewall, you get ETIMEDOUT instead.
  • You already know it's not a username / password problem; those don't generate ECONNREFUSED errors.
  • If you're connecting to a server software package (a database for example), try using that service's client program to connect from your own machine. If the client program connects, then there's something wrong with the connection data in your program:
    • Make sure you use the correct hostname or IP address.
    • Make sure you have the correct port number.
    • Make sure the server software you want to use is running on the host and port.

This error can come up when you first deploy a new project on a server after getting it to work on your own machine 127.0.0.1, localhost, or ::1.

110 questions
0
votes
0 answers

API stress test locally got ECONNREFUSED

I'm doing a stress test to my nodejs app, the test basically send a bulk of requests concurrently, sometimes I got this annoying error: { RequestError: Error: connect ECONNREFUSED 127.0.0.1:1234 at new RequestError…
Rawhi
  • 6,155
  • 8
  • 36
  • 57
0
votes
1 answer

Trouble connecting to mysql in NodeJs on Windows 10

I have tried to connect NodeJS to mysql on Windows 10, but continuously failed to. The following is the code, which from https://www.w3schools.com/nodejs/nodejs_mysql_create_db.asp var mysql = require('mysql'); var con = mysql.createConnection({ …
0
votes
1 answer

ECONNREFUSED when I request data from URL using NodeJS on company computer whilst connected to company network but I can open URL in browser

Ok, I have searched around the forums and googled for a solution but no one seems to have the exact same problem as me or at least no one has posted about it that I can find. So the problem is I can make a request (using request module) on my…
0
votes
1 answer

How to fix ECONNREFUSED error in node.js app

I'm working in a tutorial on node.js and am trying to run an app. It was working yesterday, but since adding fetch in the get request, it isn't working, I'm getting an ECONNREFUSED error. Can anyone help me fix this error? Thank you very much for…
Donny
  • 11
  • 4
0
votes
0 answers

Can't connect to mongo db on a debian VM from Windows host

I am doing doing a project where I have a mongo database on a debian VM 9.8.0 (with last virtualbox version). I have a nodejs app on my computer (Windows 10) and I want to connect this application to my mongo database. I tried a lot of things but…
0
votes
0 answers

Nativescript builds are starting to hang

I've started encountering hangs during my nativescript builds for Android. Yesterday, I got hangs after installing both a plugin and a javascript library. Today, I have had ECONNREFUSED errors when pushing the build to a device via USB as well as…
markelc
  • 354
  • 2
  • 14
0
votes
1 answer

ECONNREFUSED error in docker-compose with NodeJS and postgresql in google cloud

I have created my react app with Node.js and postgresql and I deployed in google cloud. I created a docker image of postgres and nodejs and I uploaded images to docker hub. From gcloud I accessing Those images. This is my…
0
votes
0 answers

How to solve an SQL ECONNREFUSED error in command Prompt while looking for Javascript file?

I’m trying to work with SQL to create a database and connect it to a Javascript document (all local for now). I have the following code in Javascript: var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", …
0
votes
1 answer

Android - Volley request throws ECONNREFUSED when App is closed

I have an alarm manager that runs an intentservice which fetch data from a server every minute and then sends a notification. Problem is when the app is opened i can still get the data but if the app is closed it sends it throws ECONNREFUSED. VOLLEY…
0
votes
0 answers

TCP receiver device on localhost

This is my situation (on real device, NOT emulator): I have an App_A that streams some data via TCP to another software that may be an App_B on the same device. In the App_A user manual, it is said it is possible to stream data to another app…
Timon
  • 76
  • 7
0
votes
1 answer

SocketException: Connection refused using EasyNetQ ManagementClient

I have RabbitMQ with management console installed on my machine. Web interface is working on http://localhost:15672 When I try to access Rabbit via code, I'm getting an exception: var mcGuest = new ManagementClient("http://localhost", "guest",…
Mugen
  • 8,301
  • 10
  • 62
  • 140
0
votes
2 answers

MongoError: failed to connect to server [localhost:27017] on first connect (ECONNREFUSED)

I just added MongoDB to the dependencies of my Node.js project created with the npm init command. My index.js code is: var MongoClient = require('mongodb').MongoClient , assert = require('assert'); // Connection URL var url =…
Salvatore
  • 499
  • 10
  • 16
0
votes
0 answers

Why am I getting cdiscount error "connect ECONNREFUSED"

I tried several times to register to cdiscount at https://dev.cdiscount.com/docs/gettingStarted so I can get the API key for my site. However, I keep getting the following error: connect ECONNREFUSED Could someone help me solve this problem?
Lee
  • 65
  • 1
  • 5
0
votes
1 answer

Nodejs - https.request Error: connect ECONNREFUSED

I'm trying to make a http call in my node server(URL I'm trying is the skackexchange public url), below is the code httpsServer.js var https = require('https'); function httpsRequest() { var options = { hostname:…
mkr
  • 115
  • 1
  • 4
  • 12
0
votes
1 answer

Connecting to mlab from AWS EC2

I'm trying to connect my app running on AWS EC2 to mlab endpoint. I can easily connect using the same code base from my local machine to mlab endpoint. However, when I run on AWS, I get the following error. { name: 'MongoError', message: 'connect…
pkpk
  • 641
  • 1
  • 7
  • 18