I was having the same issue when accessing a published ASP.NET Web Api. In my case, I realized that when I was about to publish the Web Api, I had not indicated a connection string inside the Databases section:
So I generated it using the three dot button, and after publishing, it worked.
What is weird, is that for a long time I am pretty sure that there was no connection string in that configuration but it still worked.