Hi elsie,
Sorry you are having trouble with importing from Facebook. A 504 Gateway Timeout error has to do with servers and not the code. It’s either Facebook or your hosting provider that has the issue. I would try contacting your hosting provider and see if they can find out what is going on.
It is the kind of thing that can be intermittent and then appear to suddenly resolve itself as the server admins troubleshoot things in the background.
If we can provide any further help. Please let us know.
— Julie