How to fix error «getaddrinfo ENOTFOUND localhost» on nuxt.js after DDoS?
Asked Answered
A

0

7

Colleagues!

Faced an unusual problem, I could not find a solution on my own. The bottom line is: there is a website on Nuxt.js in conjunction with Laravel as a backend. In server-side rendering, the frontend sends requests to the backend through localhost. During DDoS attacks (there is protection from a popular service), requests go through at the very beginning, within a minute the protection “wakes up” and the attack comes to naught.

The problem is that if the attack has a very high peak load, then the following happens.

  1. First, errors appear when exceeding the number of open files:
ERROR  EMFILE: too many open files, open '/*/*/*/app/client/static/img/image-1.svg'
ERROR  EMFILE: too many open files, open '/*/*/*/app/client/static/img/image-2.png'
ERROR  EMFILE: too many open files, open '/*/*/*/app/client/static/img/image-3.svg'
ERROR  EMFILE: too many open files, open '/*/*/*/app/client/static/img/image-4.svg'

The client folder is just a nuxt-application.

  1. When the defense repels the attack, connection errors to localhost begin:
ERROR  getaddrinfo ENOTFOUND localhost localhost:80 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)

The frontend continues to work as usual except that there is no data received during server rendering. Accordingly, 90% of the functionality falls off. When you restart the nuxt application, the work is fully restored. There are no errors in the nginx and php-fpm logs indicating a problem connecting to localhost.

I must say right away that increasing the limit on the number of open files is not a solution to the problem. With the appropriate attack power, the error will appear again.

I want to understand the reason why localhost falls off. If you can’t solve the problem in the bud, an alternative is how to catch such an error in nuxt.js to initiate a restart of the application?

Thanks in advance!

Ascension answered 16/1, 2020 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.