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
1
vote
1 answer

Nuxt.js, problem with fetching data in async fetch() hook

I'm having some trouble fetching data from my API in both the async fetch() hook and async data(). I get the error: "Error: connect ECONNREFUSED". If I try to fetch the data in the mounted() hook instead, it works normally. I've built the API in…
1
vote
1 answer

knex mysql connect ECONNREFUSED for 1 of 3 apps on same server

node.js project using express, knex, dotenv I created a copy of my project to be treated as a staging environment. It runs on the same host as my live project, but on a different port. There are no errors when I start the server. However, when I…
JLP
  • 21
  • 6
1
vote
1 answer

How to fix an ECONNREFUSED error when try to connect to a postgresql pool in nodejs

When I try bulk query in nodejs with promise.all I got ECONNREFUSED error after some number of query resulted in success. I am building node server for my web application. I made some queries resulted from AJAX requests from client. They all worked…
1
vote
1 answer

ECONNREFUSED error for create-react-app and node server

I'm builing a MERN application with create-react-app (so no custom webpack) and a node server. I'm using nodemon to restart changes on the backend, and the problem is that about half of the time it seems that my front-end tries to render before…
Cameron
  • 567
  • 1
  • 5
  • 13
1
vote
2 answers

connect ECONNREFUSED AdonisJs Mail

I just started to use the Adonisjs framework and I try to send an fake email over Mailtrap. The problem is I run always into the Error connect ECONNREFUSED…
1
vote
0 answers

Error ECONNREFUSED NodeJS MySql

I tried connecting to my first MySql server with the following code var mysql = require('mysql'); var con = mysql.createConnection({ host: "localhost", user: "yourusername", password: "yourpassword" }); con.connect(function(err) { if (err)…
Leonard
  • 11
  • 3
1
vote
2 answers

Node.JS/MySQL - Error: connect ECONNREFUSED - happening at random

I'm trying to connect to a MySQL database with Node.JS and at first, it works. Then, kinda at random, it gives the following error: Error: connect ECONNREFUSED 127.0.0.1:3306 at Object._errnoException (util.js:1031:13) at…
1
vote
1 answer

Socket error "code":"ECONNREFUSED" when trying to access remote server using nodejs

I am trying to connect to a remote server but every time i try to create a connection i get Socket error "code":"ECONNREFUSED" , "errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":"80"} My code is as follows: //create the…
BleachedAxe
  • 393
  • 2
  • 5
  • 20
1
vote
0 answers

Cloud SQL ECONNREFUSED

I am trying to use node.js App Engine with Cloud SQL, with MySQL. I am following this tutorial but my app engine does not connect with cloud sql and print this error: Error: connect ECONNREFUSED 127.0.0.1:3306 { Error: connect ECONNREFUSED…
1
vote
0 answers

Unable to install any npm package on Windows 7 connected to Internet via wifi

I am unable to install any npm package like browser-sync, gulp, grunt on my Windows 7 . I am trying to install with Admin user. I connect to net using Wifi(Netgear) where my broadband is a dial-up connection (ADSL). I have not setup any proxy…
kjyothiraditya
  • 33
  • 1
  • 10
1
vote
2 answers

nodejs request - always returning econnrefused

I have written some code using modules cheerio, request and longjohn that worked yesterday, but today it always throws the "ECONNREFUSED" error. I tried using simple sample code that uses request: var request =…
ruby
  • 13
  • 2
1
vote
0 answers

Node.js, Mongoose, MongoDB ECONREFUSED error

I am working through Pluralsight's RESTful Web Services... tutorial, but am running into an error very early on. The error is: ...\node_modules\mongoose\node_modules\mongodb\lib\server.js:228 Error: connect ECONNREFUSED at…
Flexo1515
  • 1,007
  • 1
  • 10
  • 27
1
vote
2 answers

Randomly getting ECONNREFUSED error

In the Sails.js app I'm developing, I got randomly an ECONNREFUSED error. I've tried to check the piece of code that is throwing an error, but with no luck. I already switched on the logs to verbose (NODE_DEBUG environment variable set to 'net') and…
Ze Luis
  • 236
  • 2
  • 15
1
vote
1 answer

node.js http.get() throws: events.js:72 ECONNREFUSED

I'm new to JavaScript and Node.js and trying to solve the challenge "juggling async" of learnyounode. When the error occured, I've tested my other solutions that use http.get() and all of them throw the exact same error. They worked just fine…
Flynn
  • 25
  • 4
1
vote
1 answer

Node.js express-admin "connect ECONNREFUSED"

I'm trying to get a nice admin GUI for databasing for node.js like you get from phpmyadmin. That's where I found express-admin. http://simov.github.io/express-admin-site/ I follow their instructions and installed it with no problem. When I ran the…