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

ECONNREFUSED (Connection refused) android connect to webservice

I am getting connection refused error when trying to connect to webservice using soapui. When I tried using 127.0.0.1 in the URL, the error is ECONNREFUSED but when I tried 10.0.2.2, the error is connection timed out. Please can someone help.…
user3055923
  • 195
  • 2
  • 3
  • 9
2
votes
1 answer

Why is my Web API server refusing to accept calls from Android?

I can access my Web API server from a Windows app without problems. From Android, though, is a different story Why would that be? Is "localhost" the wrong thing to use (in the URL)? Should I use the name of the computer instead? Does the string…
1
vote
1 answer

Recieving a directus webhook with a flask application (Connection Refused)

I have a directus instance running in a docker container. The docker-compose.yml looks like this: services: directus: image: directus/directus:9.22.1 ports: - 8055:8055 volumes: - ./database:/directus/database -…
1
vote
1 answer

ECONNREFUSED error with express and websockets

I am new to the world of web development. I am using HTTP endpoints to authenticate a user with JWT Tokens and I am also using the same tokens for authenticating the WebSocket connection as I am trying to implement real time chat functionality. I am…
00n00r
  • 11
  • 2
1
vote
2 answers

ECONNREFUSED connecting kibana and elasticsearch with docker compose

I try to connect kibana with elasticsearch using a docker-compose but I got the error: Unable to retrieve version information from Elasticsearch nodes. connect ECONNREFUSED XXX:9200 This is my docker-compose : version: "2.2" services: es01: …
1
vote
0 answers

Troubleshooting Mongoose Error - MongoNetworkError: failed to connect to server [localhost:27017]

I am using MongoDB 4.2 and Mongoose 5.7.0 and I am getting the following error when I try to run my app. C:\Users\Dell\Documents\23\code\newApp\node_modules\mongodb\lib\core\topologies\server.js:441 new MongoNetworkError( …
mikeym
  • 5,705
  • 8
  • 42
  • 62
1
vote
2 answers

Node.js sending data to already started socket connection

I have a Server socket and a device which uses TCP long-connection mode. They can connect and exchange data together. The node.js server is something like this: net.createServer(function (socket) { console.log('ip:port' + socket.remoteAddress…
Silvia Tacher
  • 109
  • 1
  • 2
  • 11
1
vote
0 answers

Axios -nestjs causes REFUSED, even after catching error, and NestJS app crashes

My code 1: import { HttpService } from '@nestjs/axios'; const res = await this.httpService .post(url, formData, { headers: { ...formData.getHeaders() } }) .pipe( mergeMap((value) => { return of(value); }), …
1
vote
0 answers

FetchError: request to http://localhost:3000//api/getPageInfo failed, reason: connect ECONNREFUSED 127.0.0.1:3000

In development, the project runs smoothly, but when I try to deploy on vercel I get the error Error occurred prerendering page "/". FetchError: request to http://localhost:3000/api/getPageInfo failed, reason: connect ECONNREFUSED 127.0.0.1:3000 if…
1
vote
1 answer

Error while depolying contract in near ECONNREFUSED

So I'm fairly new to Near protocol. I created a near app using npx create-near-app@latest hello-near was the default name of the near app and folder so i just pressed enter. npm install -g near-cli cd hello-near npm run build:contract So,…
Gerioch
  • 13
  • 4
1
vote
1 answer

Axios Unable to make request to IP address (Error: connect ECONNREFUSED)

I am trying to make a request to a 3rd party SOAP API, provided an IP address http://XXX.XXX.XXX.XXX:40871 I get the following error: { "success": false, "error": "connect ECONNREFUSED XXX.XXX.XXX.XXX:40871", "trace": "Error: connect…
BilalZ
  • 21
  • 1
  • 4
1
vote
1 answer

MongoDB connect ECONNREFUSED timeout in nodejs

I'm trying to work on my web-app's nodejs backend which simply handles express.js API requests and deals with my mongodb database access, however after recently switching to linux full time I seem to be unable to connect to the database from my…
Vawlpe
  • 97
  • 1
  • 8
1
vote
1 answer

Prisma ECONNREFUSED error after running prisma migrate / generate

I have a Prisma client connected to a local MySQL database inside of an express server. The server and database work fine at first and the typings are also correct. But: After running npx prisma migrate dev or npx prisma generate, nothing works…
Mark Witt
  • 25
  • 1
  • 9
1
vote
0 answers

Program connects to MySQL database with VScode extension coderunner but not with node/nodemon (ECONNREFUSED error)

Follow up of: ECONNREFUSED 127.0.0.1:3306 error connecting to MySQL database to NodeJS express server (w/ typescript) where I have made SOME progress by narrowing the issue down to "running the app through terminal as opposed to the coderunner…
1
vote
0 answers

java.net.ConnectException: failed to connect to /192.168.2.4 (port 4040) from /:: (port 57650): connect failed: ECONNREFUSED

I'm trying to make an android chat application on router wifi (As a LAN) via tcp socket. I am using the ports : 4040 For Text Data 5050 for transfering files I have coded every thing but I get the Error! java.net.ConnectException: failed to connect…
karam E
  • 25
  • 5