firebase-functions: 0.5.7
firebase-tools: 3.9.1
firebase-admin: 4.2.1
Hello. Thank you for read me.
I have the following case:
I'm trying to do an http GET request from firebase function, this is my code:
(I'm using a test API from "jsonplaceholder" just to get Random Data and then test my real functionality.)
const functions = require('firebase-functions');
const http = require('http');
exports.myFunction= functions.https.onRequest((request, response) => {
var options = {
host: 'jsonplaceholder.typicode.com',
path: '/posts/1',
};
var req = http.get(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
// Buffer the body entirely for processing as a whole.
var bodyChunks = [];
res.on('data', function(chunk) {
bodyChunks.push(chunk);
}).on('end', function() {
var body = Buffer.concat(bodyChunks);
console.log('BODY: ' + body);
})
});
req.on('error', function(e) {
console.log('ERROR: ' + e.message);
});
response.send("Hello from Firebase!"); //just to send something in response.
}
When I test that function in my LOCAL environment on a test case using node index.js, everything works just fine!
When I do firebase deploy everything deploys just fine, the function is uploaded to my function dashboard.
The expected behavior is that the log printing the body returns something like:
STATUS: 200
BODY: {
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae
ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
The actual behavior is this:
ERROR: getaddrinfo ENOTFOUND https://jsonplaceholder.typicode.com https://jsonplaceholder.typicode.com:443
Thats what's happening when I trigger the function on firebase, but in my local environment everything work ust fine.. is that a bug?
Thank you very much!
Hi, you are probably seeing this error because you need to be on a paid plan in order to make external HTTP requests from inside your function. If you look at your Functions logs from within the Firebase console, you should see error messages indicating this.
Firebase's Blaze plan (pay as you go) has a free tier for Cloud Functions, details here: https://firebase.google.com/pricing/
seeing the same error, on a payed (blaze) account
@ingvardm Please file a support ticket in that case: firebase.google.com/support
@flacohenao I am also facing the same issue.. wondering if this is resolved for you.
Error: getaddrinfo ENOTFOUND www.instamojo.com www.instamojo.com:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
I've got the same problem and error message when trying to deploy:
Error: Server Error. getaddrinfo ENOTFOUND cloudresourcemanager.googleapis.com cloudresourcemanager.googleapis.com:443
btw, problem is because on free version of firebase you can't make external network calls. call to instamojo from firebase is external. Switch to braze or paid version of firebase.
Same problem here with the blaze plan! Any solution?
Same. We have blaze account and we still get this error - everything was working normally for more than a month, and then this Monday it suddenly stopped working, without us changing anything :(
Any solution would be really appreciated!
UPDATE: Turns out our client had unpaid balance, so we got "demoted" to free plan until it is settled. For anyone experiencing this problem on blaze plan, I'd recommend contacting firebase support, they usually know why it doesn't work 馃檪
i solved it by following this few steps.
run
firebase deploy
again after the error
Error: Server Error. getaddrinfo ENOTFOUND www.gstatic.com www.gstatic.com:443
I am getting this error when I am deploying project in firebase hosting.
Please help me out to resolve this bug.
Thanking u in advance
use
firebase init hosting
but don't overwrite
then deploy
I also see the same error even on blaze plan. Can some one please help me to solve this
This issue popped up for me as well. Unfortunately, @harismoyalan's solution didn't work for me.
I was able to resolve this by purging and reinstalling my node_modules directory. I'm not sure why this would have fixed it considering my package-lock.json file was unchanged (which should mean barring messing with the packages, it _should_ have been identical to the directory before the purge.
If this doesn't work for you, try purging and reinstalling your global firebase cli. Since I don't have it installed globally, it was covered when I reinstalled my node modules.
use firebase deploy before your actual command.
it worked for me :)
Hi, you are probably seeing this error because you need to be on a paid plan in order to make external HTTP requests from inside your function. If you look at your Functions logs from within the Firebase console, you should see error messages indicating this.
Firebase's Blaze plan (pay as you go) has a free tier for Cloud Functions, details here: https://firebase.google.com/pricing/
Is making a http request to google sheets is external ?
Add did it changed last month as I can check till 28th of the last month everything was working fine.
Worked for me after I opened up my VPN and running firebase deploy again.
The same issue with Blaze plan, did several deployments, the the same result :
Error: getaddrinfo ENOTFOUND https://test.oppwa.com https://test.oppwa.com:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Submitted the ticket to Google support !
use firebase deploy before your actual command.
it worked for me :)
Does this imply you can't run locally? I was on the basic plan, upgraded to blaze, still seeing the same error noted above.
Update
Since I am working from a local server, i switched my databaseURL to localhost "..." and the error was resolved, for now.
For me, turns out I needed to create a new Terminal instance, since I recently installed npm.
my issue was insufficient space on my machine's storage, clearing up space fixed it
i solved it by following this few steps.
run
firebase deploy
again after the error
Thank you! It worked!!!
Most helpful comment
i solved it by following this few steps.
run
firebase deploy
again after the error