I
I
iamkinghere2020-01-15 13:35:44
JavaScript
iamkinghere, 2020-01-15 13:35:44

How to fix "getaddrinfo ENOTFOUND localhost" error in nuxt.js after DDoS?

Hello colleagues!
I ran into an unusual problem, I did not manage to find a solution on my own. The bottom line is this: there is a website on Nuxt.js in conjunction with Laravel as a backend. With server rendering, the frontend sends requests to the backend via localhost. During DDoS attacks (there is protection against a popular service), at the very beginning, requests pass, within a minute the protection "wakes up" and the attack disappears.
The problem is that if the attack has a very high peak load, then the following happens.
1. First, there are errors of exceeding the number of open files:

ERROR  EMFILE: too many open files, open '/*/*/www/app/client/static/img/image-1.svg'
ERROR  EMFILE: too many open files, open '/*/*/www/app/client/static/img/image-2.png'
ERROR  EMFILE: too many open files, open '/*/*/www/app/client/static/img/image-3.svg'
ERROR  EMFILE: too many open files, open '/*/*/www/app/client/static/img/image-4.svg'

The client folder is exactly the nuxt application.
2. 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 for the fact 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 completely 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 value of limits on the number of open files is not a solution to the problem. With the appropriate attack strength, the error will appear again.
I want to understand the reason why localhost falls off. If you can't solve the problem at the root, the alternative is how to catch such an error in nuxt.js in order to initialize the application reload?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question