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

MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 But my mongod service is running

Every time I run npm start in my backend folder, my server runs successfully for a short time and then soon after crashes. I'm getting this error back from the command line: [nodemon] restarting due to changes... [nodemon] starting `babel-node…
Paradox_0
  • 3
  • 4
0
votes
1 answer

Error "connect ECONNREFUSED XXX.XX.XX:XX" while trying to "npm install" any module

So... Today I installed VS Code and Node.js on office's computer. My initial idea was to code an quick app to edit some excel sheets. When I tried to install a module, the following error was returned: npm ERR! code ECONNREFUSED npm ERR! syscall…
0
votes
1 answer

I can't access to mySQL with node js anymore

I have updated my node version, and now I can't access to my DB with my app. I tried many things: -Change rout to 127.0.0.1. -add my port number 3306 -add socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock' -kill node running And probably others,…
0
votes
1 answer

Application error deploying my node.js project on Heroku

When running heroku --tail logs I get the following error response : error: 2022-01-25T19:10:06.153750+00:00 app[web.1]: at emitErrorCloseNT (node:internal/streams/destroy:122:3) 2022-01-25T19:10:06.153750+00:00 app[web.1]: at…
SD Penedo
  • 33
  • 4
0
votes
0 answers

socket connect() returns ECONNREFUSED but netcat connects happily

I have a strange problem: I have written a c++ programm which is supposed to connect to ip enabled scales. It is using standard c++ sockets. When I run the programm against real device (address 192.168.30.200 port 23) i am getting errno=ECONNREFUSED…
Damago
  • 101
  • 6
0
votes
0 answers

Error: connect ECONNREFUSED 192.168.0.27:3306

I am trying to create a connection between Visual Studio Code and MS SQL Server Management Studio 18. I have found numerous tutorials that have the same code that I pretty much just copied and pasted. const mysql = require('mysql'); //create…
0
votes
1 answer

Node.JS Express connect to Mysql (both Docker) ECONNREFUSED

I'm trying to connect express to mysql that running in docker FYI. both of them running in docker It works when express runs in my local but not work when trying to run in docker error code from docker : error connecting: Error: connect…
0
votes
1 answer

Error occurred while proxying request localhost:3000/api/product to http://localhost:5000/

We are trying to create an simple eCommerce app using Typescript, express and nextjs. When we make a request to it, it throws the following error. [HPM] Error occurred while proxying request localhost:3000/api/product to http://localhost:5000/…
codewithsg
  • 404
  • 4
  • 11
0
votes
0 answers

Heroku deployement error connect ECONNREFUSED 127.0.0.1:27017

This is my code for mongodb atlas connection, it shows connection successful but later when I click on some tab the app crashes. I m deploying app through heroku and i have given the error below .app runs fine on localhost but crashes on the heroku…
0
votes
1 answer

chrome remote interface ECONNREFUSED 127.0.0.1:9222

I am using Testcafe and it does not have direct support to access Chrome Dev Tools. My Aim is to cut the network so that I can see the error dialog in the website. This is the code that I have written. TestCafe opens at a different url Here is the…
0
votes
1 answer

My ubuntu server can’t connect to binance websockets with nodejs (errno: -111 | code: 1006 ECONNREFUSED)

Im getting this message when i try websockets connection with nodejs: [ 'WebSocket error: heStzDmfg5HKgWKGUHwrGss2EXhnB29vXeNsIay55NNAG7FUx7RuelXQXaKW (ECONNREFUSED) connect ECONNREFUSED 52.198.55.31:9443' ] [ Error: connect ECONNREFUSED…
0
votes
2 answers

net.createConnection ECONNREFUSED

net.createConnection always seems to give ECONNREFUSED. I did a tcpdump and don't quite know what I'm looking for. Code: const net = require('net'); const client = net.createConnection({ port: 8124}, () => { // 'connect' listener. …
ZiiM
  • 31
  • 1
  • 6
0
votes
1 answer

SendGrid + Ruby on Rails 6 on DigitalOcean Apps + Errno::ECONNREFUSED (Connection refused - connect(2) for "localhost" port 25):

I believe this error is about ENV API Key. This works fine on my localhost but on server. I added my API key to Components / Environment Variables: and my development.rb file. as below: config.action_mailer.delivery_method = :smtp …
0
votes
1 answer

I get this error message when I try to test run my MySQL database

this is my database code var con = mysql.createConnection({ host: "localhost", user: "root", password: "", port: "889", }); con.connect(function(err) { if (err) throw err; console.log("Connected!"); con.query("CREATE DATABASE…
AmmanM
  • 97
  • 7
0
votes
1 answer

I can't start MySQL server in NodeJs after reset MySQL password using Windows's cmd

I reset my MySQL password using cmd commands from this guide. cd "C:\Program Files\MySQL\MySQL Server 8.0\bin" mysqld --defaults-file="C:\\ProgramData\\MySQL\\MySQL Server 8.0\\my.ini" --init-file=C:\\Users\\\\resetMYSQL.txt resetMYSQL…
KradasA4
  • 165
  • 1
  • 2
  • 11