Firebaseで「getaddrinfo ENOTFOUND」というエラーが出る

TwitterBot
スポンサードリンク
スポンサードリンク

FirebaseでTwitterのAPIが叩きたかった

Node.jsのtwitterライブラリを使ってTLを読み込みたかったんですけど、実行する過程で以下のようなエラーがでました。

{ Error: getaddrinfo ENOTFOUND api.twitter.com api.twitter.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'api.twitter.com',
  host: 'api.twitter.com',
  port: 443 }

原因なんですけど、以下の記事を参考にしました。

Node.js getaddrinfo ENOTFOUND - Stack Overflow

When using Node.js to try and get the ht…
stackoverflow.com

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.

つまり無料プランだと外部のHTTPリクエスト(ここではTwitterのAPIを叩くこと)は作れないという結論でした。

おしまい

叩きたい人は従量課金制のBlazeプランに入ると使えるらしいですよ。