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
0 answers

DataGrip connect mysql

this my error: DBMS: MySQL (no ver.) Case sensitivity: plain=mixed, delimited=exact Connection refused: connect. please help me solve, My English is not good thanks I tried to find the answer on the Internet, but it didn't work this idea.log: The…
mmt
  • 1
  • 1
0
votes
0 answers

I can not get Wordpress to connect to my SMTP server

I am trying to get my Wordpress site (running on aiauto.cloud to send out email via my emailserver running in on server.cybxpert.com port 25251. I have run GMASS SMTP Test Tool and it connects, and checked with Telnet - "Server Ready". But ALL of…
Dave
  • 27
  • 4
0
votes
0 answers

GetServerSideProps NextJs brokens in production

I have getServerSideProps function in NextJs12 looks like: export const getServerSideProps: GetServerSideProps = async (ctx) => { const shouldRedirect = await checkPermission({ permissionCode: PERMISSION_CODES.CA_MANAGE, type: 'create' },…
0
votes
1 answer

ECONNREFUSED error during testing with Vitest 0.32.0 + Node JS + Express

I'm experiencing a problem while running tests on my Express backend using Axios for making requests and Vitest for test execution. Here are the details: I have my backend running on localhost, port 3000, using Express. I am using Vitest for…
0
votes
0 answers

Proxy error: Could not proxy request /api/rawsRoute from localhost:3000 to http://localhost:5000/. (ECONNREFUSED) caused by nodemon

I have a MERN stack project in which I use nodemon to run the backend server. In the client side, I have an upload button which lets users upload files into a local directory called cache located in the backend. Then I have a route in the backend…
Ruo
  • 77
  • 7
0
votes
0 answers

MongoDB locally ECONNREFUSED to connect to server even after locally running server correclty

MongoServerSelectionError: **connect ECONNREFUSED 127.0.0.1:27017** at Timeout._onTimeout (c:\Users\acer\Documents\nodejs\task-manager\node_modules\mongodb\lib\sdam\topology.js:285:38) at listOnTimeout (internal/timers.js:554:17) at…
0
votes
0 answers

AxiosError: connect ECONNREFUSED 127.0.0.1:3000

First question I'm asking, hoping for a "miracle", safe to say I'm a Jr Developer: I have a NextJs project and I am using Prisma & Supabase. I made it very simple, I only have one item in the database, one index.js page with a getserversideprops…
0
votes
1 answer

Can't connect node js with mysql in docker container

error message I am facing after running docker composee Express server is runnig at port no : 8000 backend-web-1 | DB connection failed backend-web-1 | Error : { backend-web-1 | "errno": -111, backend-web-1 | "code":…
Sherwin
  • 1
  • 2
0
votes
1 answer

StackBlitz - ECONNREFUSED when connecting to local machine

I'm running a simple express server on my machine and attempting to ping it from a StackBlitz web container, but am getting the following error when trying to connect: FetchError: request to https://192.168.1.23:8443/ failed, reason: connect…
chantey
  • 4,252
  • 1
  • 35
  • 40
0
votes
0 answers

Any ideas why using localhost instead of 127.0.0.1 would cause a connection error?

For context, I am using the reactjs gatsby framework which provides a plugin to connect to a strapi backend. When specifying the strapi api url as "localhost", it throws an error "econnrefused". Yet, when using "127.0.0.1", the error is resolved. I…
ahpto
  • 11
  • 5
0
votes
1 answer

MongooseServerSelectionError: connect ECONNREFUSED 0.0.0.0:27017

So I wanted to try making like a blog website with Node js and MongoDB. I’m a beginner with it so it’s kinda a mess, but everything worked fine locally (on localhost 3000). I found Railway as a free alternative to Heroku and tried to deploy my…
0
votes
1 answer

node-fetch connect ECONNREFUSED for fetching my api on vps server

I have been working on a NodeJS express app that uses EJS and node-fetch to fetch my Api from my vps server, but it won't get fetched, every page of the app will load but the page that uses the Api where I am fetching the Api won't work, I have been…
ZeyoYT
  • 11
  • 3
0
votes
0 answers

Error connect ECONNREFUSED 127.0.0.1:8000 at try fetch to localhost:8000 in NextJs

I would like to make a good query that I have not been able to solve anywhere, I need to use a plugin that prints to a thermal printer, but it throws me an error connect ECONNREFUSED 127.0.0.1:8000, first I had CORS problems and looking for it I…
0
votes
0 answers

Error: getaddrinfo EAI_AGAIN undefined at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:26)

I ran mocha tests in node.js. The following are the details related to it [includes the error] github actions workflow: default node js github actions name: Node.js CI on: push: branches: [ "master" ] pull_request: branches: [ "master"…
0
votes
2 answers

connect ECONNREFUSED 127.0.0.1:27017 in Mongodb Compass

I restarted my computer to try to update it, and before restarting, I was also working on another project. Now, my project with a node.js backend is giving me this error: reason: TopologyDescription { type: 'Single', setName: null, …
Gigi101
  • 139
  • 1
  • 11