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"?

viren dhanwani 1 Reputation point
2019-12-04T06:16:45.423+00:00

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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,931 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 22,436 Reputation points Microsoft Employee
    2019-12-10T11:32:57.523+00:00

    @viren dhanwani , 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.

    0 comments No comments