axios request Error: connect ECONNREFUSED

Posted on

axios request Error: connect ECONNREFUSED

axios request error in firebase cloud function. here is my code.

import * as functions from 'firebase-functions';
import axios from 'axios';

export const mobileDoUpdate = 
.onUpdate((snapshot, context) => {

.then(response => {
.catch(error => {


the error is showing me Error: connect ECONNREFUSED
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
how can I solve it? help me please.

Solution :

You can’t make requests to localhost when running on Cloud Functions. That’s never going to work. You’re going to need a full proper URL for the host or service you’re trying to contact, and it’s certainly not going to be localhost. localhost always means IP address, which is the same machine where the request is originating. Once you’ve deployed this code, localhost becomes the Cloud Functions server instance where the code is running, not your desktop machine.

Leave a Reply

Your email address will not be published. Required fields are marked *