Issue with Loki as a data source

Hi everyone, I have an issue when trying to add Loki as my data source. Loki is running locally, but Grafana is deployed on the server. Could this be causing the problem? I received an error message: 'Loki: Bad Gateway. 502. Bad Gateway.