简体   繁体   English

PG::ConnectionBad 无法连接到服务器 - heroku 本地 rails 应用程序

[英]PG::ConnectionBad could not connect to server - heroku local rails app

I was trying to run heroku local or heroku local web and everything was working fine.我试图运行heroku localheroku local web ,一切正常。 After importing the data from my heroku remote to my local environment, it started to throw me the following error:将数据从我的 heroku 远程导入到本地环境后,它开始向我抛出以下错误: 在此处输入图片说明

After searching for the solution in some places, I tried restarting the postgresql service with brew services restart postgresql and it started normally but I kept receiving the error.在某些地方搜索解决方案后,我尝试使用brew services restart postgresql ,它正常启动但我一直收到错误消息。 I also tried to delete the postmaster.pid as suggested on this SO post PG::ConnectionBad - could not connect to server: Connection refused but didn't find the file.我还尝试按照此 SO post PG::ConnectionBad 中的建议删除postmaster.pid - 无法连接到服务器:连接被拒绝但未找到该文件。

Well, finding the solution was easier than I thought.好吧,找到解决方案比我想象的要容易。

On this same post ( PG::ConnectionBad - could not connect to server: Connection refused ) it suggested to check the logs before deleting the file and I did even that I haven't finding the file to be deleted.在同一篇文章中( PG::ConnectionBad - 无法连接到服务器:连接被拒绝),它建议在删除文件之前检查日志,我什至没有找到要删除的文件。

When I checked the logs, I came across the following:当我检查日志时,我遇到了以下问题: 在此处输入图片说明

So, I checked the heroku's Postgres version and it uses the 12 as default but brew uses the latest, which is the 13th.因此,我检查了 heroku 的 Postgres 版本,它使用 12 作为默认版本,但brew使用最新版本,即第 13 个版本。

To sum up, I did a dump from a Postgre v12 to Postgre v13 and this is incompatible, so I'm going to downgrade my local Postgres to work with my data as expected.总而言之,我从 Postgre v12 转储到 Postgre v13,这是不兼容的,所以我将降级我的本地 Postgres 以按预期处理我的数据。

To do that, I did the following:为此,我执行了以下操作:

brew uninstall postgres - to remove v13 brew uninstall postgres - 删除 v13

brew install postgresql@12 - to install a specific version brew install postgresql@12 - 安装特定版本

brew services start postgresql@12 - to start the new version brew services start postgresql@12 - 启动新版本

Cool fact, I didn't need to restore or modify the data because it wasn't deleted even uninstalling the Postgresql.很酷的事实,我不需要恢复或修改数据,因为即使卸载 Postgresql 也没有删除数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PG :: ConnectionBad:无法连接到服务器(heroku) - PG::ConnectionBad: could not connect to server (heroku) PG :: ConnectionBad,无法连接到服务器 - PG::ConnectionBad, could not connect to server PG ConnectionBad 无法连接到服务器 - PG ConnectionBad Could not connect to server Heroku:PG :: ConnectionBad:无法连接到服务器:没有这样的文件或目录 - Heroku: PG::ConnectionBad: could not connect to server: No such file or directory Heroku:PG :: ConnectionBad:无法连接到服务器:连接被拒绝 - Heroku: PG::ConnectionBad: could not connect to server: Connection refused Rails-Postgres-无法连接到服务器:连接被拒绝(PG :: ConnectionBad) - Rails - Postgres - could not connect to server: Connection refused (PG::ConnectionBad) PG :: ConnectionBad:无法连接到服务器:使用passenger,nginx和capistrano部署Rails应用程序后 - PG::ConnectionBad: could not connect to server: after deploying rails app using passenger, nginx and capistrano PG::ConnectionBad - 无法连接到服务器:连接被拒绝 - PG::ConnectionBad - could not connect to server: Connection refused PG :: ConnectionBad:无法连接到服务器:连接被拒绝 - PG::ConnectionBad: could not connect to server: Connection refused 无法连接到服务器:没有这样的文件或目录(PG::ConnectionBad) - could not connect to server: No such file or directory (PG::ConnectionBad)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM