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
3
votes
2 answers

Android ECONNREFUSED (Connection refused)

I have tried to send data to server with this code from my android application. try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://myip/adminlogin.php"); httpPost.setEntity(new…
appkovacs
  • 97
  • 1
  • 1
  • 9
3
votes
2 answers

Node-Thermal-Printer Not Connecting to Epson T88IV Printer

I am trying to print to an Epson TM-T88IV printer from javascript. (This is a thermal receipt printer.) Status: The printer is connected to the network via ethernet. I can successfully ping the printer. I can access the printer web configuration…
Kevin Kurpe
  • 61
  • 1
  • 6
3
votes
1 answer

Why I don't get an error when I connect more sockets than the argument backlog given to listen?

I have a passive socket that listen connections like this: t = listen(fd, 1); fd is the file descriptor of the socket created before. As you can see and if I understand well, listen() should be able to place only one incoming socket in its queue…
Simon
  • 6,025
  • 7
  • 46
  • 98
3
votes
1 answer

java.net.ConnectException: failed to connect to /103.XX.XX.38 (port 8080): connect failed: ECONNREFUSED (Connection refused)

I am new in android world . I trying to developer a app where i try to download and install .apk from unknown sources. Actually my this .apk is kept on development server of Url address http://103.XX.XX.38:8080/apk/HelloAndroid.apk. This url is…
DJhon
  • 1,548
  • 3
  • 22
  • 39
2
votes
0 answers

Error occurred (ECONNREFUSED) while trying to proxy request React/ Express (npm run start)

Hello and hope you are well. When running npm run start on my project, it is not working because it seems to build the files only once and not watch for it. So it is not compiling the FE part and only running server side. package.json "scripts": { …
Edith
  • 43
  • 2
2
votes
2 answers

Docker Redis Error: connect ECONNREFUSED 127.0.0.1:6379

I'm following a tutorial from youtube creating a simple dockerized CRUD application in Express, Node.js, Mongo & Redis. I stucked at video 3:06:57 on Authentication with sessions & Redis. The initial issue I faced below when I send a…
A_T
  • 21
  • 1
  • 4
2
votes
1 answer

Why do I get ECONNREFUSED in the terminal, but not the browser?

I have a very simple nodejs program that I am using to demonstrate communication with the Alchemer API. Whenever I run the following code, an error is thrown with the code ECONNREFUSED. However, when I copy the same url into the browser or…
Reilly
  • 107
  • 1
  • 6
2
votes
2 answers

Node.js Github API connect ECONNREFUSED error getting user repos

I'm locally attempting to get user repos via https get request with https.get const https = require("https") https.get({ url: "https://api.github.com/users/ryanve/repos" }, response => { let data = "" response .on("data", chunk…
ryanve
  • 50,076
  • 30
  • 102
  • 137
2
votes
2 answers

Connection refused when connecting to redis on EC2 instance

I am trying to connect to local redis database on EC2 instance from a lambda function. However when I try to execute the code, I get the following error in the logs { "errorType": "Error", "errorMessage": "Redis connection to 127.0.0.1:6379…
Rohit
  • 23
  • 2
  • 3
2
votes
2 answers

ECONNREFUSED error in NodeJS + MySQL web app

I have web app running on NodeJS + MySQL. Initially the web app works fine,but all of a sudden the MySQL connection gets refused with following error being thrown: ECONNREFUSED 127.0.0.1:3306 Simply restarting the server with pm2 reload solves the…
Ayan
  • 8,192
  • 4
  • 46
  • 51
2
votes
2 answers

nodeJS request POST To localhost:3000 ECONNREFUSED

At one point I just want to make a POST request to my rails server running on localhost:3000 If a use like postman on even cUrl I can ping my API But kow, with my node app I want to do this : var req_body = { 'my_id': id, …
F4Ke
  • 1,631
  • 1
  • 20
  • 49
2
votes
1 answer

kibana not able to connect to server elasticsearch index - ECONNREFUSED

I have elasticsearch server running having indexes, say server XX.XXX.XXX.XXX:9200. I have index in the server ES cluster XX.XXX.XXX.XXX:9200 for which I am trying to create dashboards in my localhost:5601 (Kibana) In my kibana.yml I have this…
2
votes
1 answer

ECONNREFUSED errors on UDP sendto

I am experiencing some unexplained behavior with an app that is writing UDP data with sendto() to multiple ports (all opened with socket(PF_INET, SOCK_DGRAM, 0)) for the benefit of a set of client reading processes. These sendto()s occasionally and…
Roger Davis
  • 41
  • 1
  • 2
2
votes
0 answers

Appium server throwing Unhandled error: Error: connect ECONNREFUSED

I'm using appium 1.4. Just before client connection to appium server, an appium server socket is created on port 4274. But when client is trying to connect it gets the following exception: 2015-06-03 08:52:32:541 - info: [debug] [BOOTSTRAP] [debug]…
2
votes
1 answer

ECONNREFUSED When Trying to Install Anything with NPM

I'm trying to learn Nodejs, but every time I try installing modules from NodeSchool; specifically "how-to-node" & "learnyounode". I'm getting "ECONNREFUSED" when trying to run anything. Can anyone shed a little light as to why I keep getting this?…
lukeslytalker
  • 39
  • 1
  • 10