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
188
votes
20 answers

Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

I working with node.js by expressjs I try to store an account to session. So, i try to test to use session with code in expressjs var RedisStore =…
Huy Tran
  • 4,371
  • 10
  • 34
  • 38
32
votes
2 answers

node.js - handling TCP socket error ECONNREFUSED

I'm using node.js with socket.io to give my web page access to character data served by a TCP socket. I'm quite new to node.js. User ----> Web Page <--(socket.io)--> node.js <--(TCP)--> TCP Server The code is mercifully…
Chris Mead
  • 465
  • 1
  • 4
  • 9
20
votes
8 answers

node.js mysql error: ECONNREFUSED

Why can't I connect to the mysql server? On the same server an Apache/PHP server is running and it connects without problems!? var mysql_link = { host : 'localhost', port : 3308, database: 'nodetest', user : 'root', password :…
clarkk
  • 27,151
  • 72
  • 200
  • 340
9
votes
2 answers

ECONNREFUSED when fetching from localhost:3000 to localhost:8000 (Nextjs - DjangoApp)

When trying to make a 'POST' request using the 'fetch' node function, between the frontend and the backend (React Next.js and Django), I got an 'ECONNREFUSED' error. Backend requests using Postman worked as expected. Django is on port: 8000 and…
Tomas Le Blanc
  • 121
  • 1
  • 5
9
votes
1 answer

What causes ECONNREFUSED on UNIX Domain Sockets?

In TCP servers, I understand that a Connection Refused would either be because the The process stopped listening, by calling close on the server-socket (existing connections stay open, and new connections are refused), or The process ended, or The…
700 Software
  • 85,281
  • 83
  • 234
  • 341
6
votes
2 answers

Jest test failing with 'connect ECONNREFUSED 127.0.0.1:80' when app is listening on port 3000 (express and supertest)

I am struggling to resolve a bug in my jest test using supertest, I think it is an issue with my test rather than my code. My issue I am trying to create a back end API using node.js and express, using TDD. I have the following files to set up the…
Tom
  • 93
  • 1
  • 1
  • 8
5
votes
2 answers

ECONNREFUSED for proxy request from localhost to another localhost

To begin, I'm new to angular and I'm following a tutorial video step by step. I've been stuck on this issue for nearly 2 weeks and have spent many hours looking for solutions in other similar forums. I realize this is a common error, but after…
dimly_lit_code
  • 113
  • 1
  • 2
  • 8
4
votes
0 answers

ECONNREFUSED api call to strapi from nextjs with nginx dockerdocker

I have a docker container with strapi, nextjs and nginx. I have it set up so that if I navigate to front.development I hit the next front end and if I go to back.development I hit the strapi backend. I can make a request to…
Mike
  • 41
  • 2
4
votes
4 answers

ECONNREFUSED on running localhost server from NodeJS

I have a NodeJS server up and running on my local machine that is listening to port 50000. From another server, that is also running on my local machine, I need to make a simple GET request to that server, but all I get is an ECONNREFUSED error: {…
Guest9875
  • 63
  • 1
  • 2
  • 8
4
votes
3 answers

Can't connect nodejs and mysql in same docker

I'm new in docker and i'm trying to make my nodejs express run inside it. I'm trying to install the dependencies using shellscript and its working but in the end I can't connect to mysql. My docker file install mysql, create an user and a database,…
Jean Robert
  • 749
  • 1
  • 7
  • 20
4
votes
1 answer

ocsigenserver.opt fails on startup with Unix.ECONNREFUSED

My ocsigen server has been working fine for a while, but just as I'm about to show it off to someone, it spews this on startup and then exits with failure: ocsigenserver.opt: ocsipersist:dbm: Cannot connect to Ocsidbm. Will continue without…
unhammer
  • 4,306
  • 2
  • 39
  • 52
3
votes
1 answer

Error: connect ECONNREFUSED ::1:3306 is when i try to use typeorm in nestjs

This error when i try to use typeorm in nestjs i did setting for using typeorm like this app.module.ts import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; import { ApolloDriver, ApolloDriverConfig } from…
JuHongPark
  • 45
  • 2
  • 7
3
votes
1 answer

git push returns Missing or invalid credentials. code: 'ECONNREFUSED', remote: Repository not found

I was able to push to 'myrepo' from my terminal without any issues until recently. Now, I am getting this - Missing or invalid credentials. Error: connect ECONNREFUSED /run/user/4714/vscode-git-b650b12c34.sock at PipeConnectWrap.afterConnect [as…
rohit_r
  • 623
  • 1
  • 6
  • 18
3
votes
0 answers

Postgresql-Nodejs connection error (ECONNREFUSED) Windows 10

A couple of weeks ago I started a blog app. For this I used postgresql as database on the backend. Back then, the application worked fine I was able to fetch data from the frontend to the backend server running express. Today I decided to visit the…
ExellentCoin
  • 31
  • 1
  • 3
3
votes
2 answers

error : connect ECONNREFUSED

I am running a node app with mysql as my database(also using sequelize as ORM). Whenever I run the "app.js" file with "node" command, I get an error: { [Error: connect ECONNREFUSED 127.0.0.1:3306] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', …
Seth Harlaar
  • 124
  • 2
  • 2
  • 13
1
2 3 4 5 6 7 8