This problem was annoying because of SharePoint lousy error messages that make no sense.
In my case the issue was the existence of two front-end machines which sites did not point to each other correctly. What I had to do was to configure the hosts file(C:\Windows\System32\drivers\etc\hosts) for each site to properly point to from one server to another. Initially in this environment only one server was pointing correctly to the other server but not the other.
This problem is of course limited when testing from the server machines themselves.