Postgres error - could not connect to server: No such file or directory #25137
-
Hello - hoping someone can point me in the right direction. Trying to get an action working for Rails with Postgres support. Got the authorization bit sorted out (finally!) but now am at this error:
This looks vaguely familiar to me. I had an issue like this with the Docker image on my local machine and I ended up have to specify a Here is my ruby.yml configuration setup:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @thornomad , In the last step, you can access the service container using localhost and the mapped port directly.
Please refer to the doc here for more details. If it doesn’t work, please kindly share your repo/sample repo for further investigation. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hello @weide-zhou - thanks for taking time to help me. I have another repo I had used for a different test (basic rails app that uses postgres with no real configuration). I added the github action to that app in its own branch to demonstrate the failure I am having. You can see the action setting at: https://github.com/thornomad/issue-38279-rails-6/blob/add-github-action/.github/workflows/ruby.yml I am taking a guess at the config/database.yml setup. I added the password, username, and port evn variables there. https://github.com/thornomad/issue-38279-rails-6/blob/add-github-action/config/database.yml#L58-L63 Finally, here is the output from the action. Am having the same issue as with the other application. https://github.com/thornomad/issue-38279-rails-6/runs/564539190?check_suite_focus=true Thanks again. I feel like all my searching online and trying different examples floating around and I am getting stuck. Must be something fundamental that I am missing! |
Beta Was this translation helpful? Give feedback.
-
Hi @thornomad , Thanks for your reply! I forked your repo and did some changes, now the error is gone:
My workflow run here: https://github.com/weide-zhou/issue-38279-rails-6/runs/566774300?check_suite_focus=true You can refer to the link for more details. Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
Hi - thanks for working with me on this. It looks like the issue in the end was not defining For anyone else who stubmles across this; here is what ended up working for me on a new Rails 6 setup using postgres. This let’s both the local machine testing environment and github actions do its thing! Thanks again!
And then the relevant section from
Thanks again! |
Beta Was this translation helpful? Give feedback.
Hi @thornomad ,
Thanks for your reply! I forked your repo and did some changes, now the error is gone:
In config/database.yml, change to use below code, use ‘adapter’ & ‘host’ parameter:
test:
<<: *default
database: test_app_6_test
adapter: postgresql
host: localhost
encoding: unicode
username: <%= ENV[“POSTGRES_USER”] %>
password: <%= ENV[“POSTGRES_PASSWORD”] %>
The workflow file:
name: Ruby
on: [push]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
u…