So I have a rails application that I built and deployed via AWS Elastic Beanstalk a few months ago. The project was put on hold so I terminated the environment, expecting to be able to re-deploy when we returned to this project.
Despite my app still running just fine on my local dev environment, I cannot get it to deploy. The error from my eb-activty.log
:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
The database is a standalone AWS RDS instance that I can successfully test the connection to, so I know its running. I have added the requisite environment variables and configured my database.yml
accordingly. To be clear, this is an application that used to work. I hadn't made any changes between the time I terminated the environment and when I went to re-deploy.
The root problem seems to be that nginx isn't being configured properly, as trying to access the server returns:
502 Bad Gateway
nginx/1.12.1
and when I check the nginx error.log
its filled with errrors like this:
2018/09/19 14:12:35 [crit] 3069#0: *653 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.47.147, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/", host: "172.31.47.147"
Naturally, I googled my error, and found this stackoverflow post.
I've tried adding these suggested lines from the top-rated answer to my puma.rb
bind "unix:///var/run/puma/my_app.sock"
pidfile "/var/run/puma/my_app.sock"
Which caused no change at all.
I made sure to try the other suggestions, including having a direct look at the nginx configuration file. I did find that there's no upstream set up in the config. As best as I can see, the nginx aspect of the deployment pipeline is automated by Elastic Beanstalk so clearly something else I've set must be incorrect.
I've found that under no circumstances can I get the app to deploy using eb deploy
I can only make changes by creating a new environment each time. I've recreated the app countless time, experimenting with different settings, versions of gems and packages, different ruby versions...etc. All in all, I still can't affect change on the error, I can't even get a new error! just the same PG:ConnectionBad
or 502 bad gateway
depending on if I look from console or browser.
From my googling I've come under the impression that this is related to puma in some regard but puma is a bit of a black box for me.
I'm feeling pretty lost here, I'd really appreciate any guidance you'd be willing to share. Feel free to ask for more info from any log or file, I'm happy to provide more detail. Thanks in advance!