question

virendhanwani-0632 avatar image
0 Votes"
virendhanwani-0632 asked ·

PG::ConnectionBad: could not connect to server: No such file or directory precompilation failed Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I am trying to deploy Ruby on Rails app on Azure app service on Linux through Local git deployment method. But the deployment fails with the following error:

PG::ConnectionBad: could not connect to server: No such file or directory precompilation failed Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

alt text

I have already provisioned Azure Database for Postgresql with firewall rule allowing all IP and Allow access to azure services is turned ON. I can access the database through psql command and also run database migrations successfully.

Please suggest/tell how to get rid of this error and successfully deploy the app.


azure-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ajkuma-MSFT avatar image
0 Votes"
ajkuma-MSFT answered ·

@virendhanwani-0632, Welcome to Microsoft Q&A! Thanks for posting this question.

It appears that you're deploying the WebApp locally and facing this issue. Typically, if the App doesn't work locally, it almost never works on Azure. Firstly, I suggest you to isolate the issue locally; it appears to be a Rails configuration issues, so kindly review docker-compose.yml for the database configuration (for custom docker case).

Generally, for a database connection problem - On all firewalls between the client and the internet, make sure that port 5432 is open for outbound connections and also verify your connection string and other connection settings.

Note that on Azure App Service, the Ruby development stack only supports Ruby on Rails at this time. If you want to use a different platform, such as Sinatra, or if you want to use an unsupported Ruby version, you need to run it in a custom container.
Run az webapp list-runtimes --linux to view the latest languages and supported versions

Additionally, on Azure WebApp side, when your application fails to start or you want to check the logging from your app, check the Docker logs in the LogFiles directory. You can access this directory either through your SCM site or via FTP. To log the stdout and stderr from your container, you need to enable Application Logging under App Service Logs. The setting takes effect immediately. App Service detects the change and restarts the container automatically.

To access the Application Event Log, use the Diagnose and solve problems blade in the Azure portal.
1. In the Azure portal, open the app in App Services.
2. Select Diagnose and solve problems.

Kudu Console - http://yourwebappname.scm.azurewebsites.net >'Log stream' for logs.

Kindly let us know how that goes for further investigation.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.