<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ben Purinton</title>
    <description>The latest articles on DEV Community by Ben Purinton (@bendirtdev).</description>
    <link>https://dev.to/bendirtdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2940286%2F74d1dce7-98eb-49fd-926a-bde9e1c708f7.jpg</url>
      <title>DEV Community: Ben Purinton</title>
      <link>https://dev.to/bendirtdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bendirtdev"/>
    <language>en</language>
    <item>
      <title>Setting the correct database connection on production with Render</title>
      <dc:creator>Ben Purinton</dc:creator>
      <pubDate>Thu, 13 Mar 2025 18:16:31 +0000</pubDate>
      <link>https://dev.to/bendirtdev/setting-the-correct-database-connection-on-production-with-render-5dm5</link>
      <guid>https://dev.to/bendirtdev/setting-the-correct-database-connection-on-production-with-render-5dm5</guid>
      <description>&lt;p&gt;While deploying a Rails 8 app on Render today, I faced this issue in the deployment log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ActiveRecord::ConnectionNotEstablished: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (ActiveRecord::ConnectionNotEstablished)
    Is the server running locally and accepting connections on that socket?
Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (PG::ConnectionBad)
    Is the server running locally and accepting connections on that socket?
Tasks: TOP =&amp;gt; db:migrate
(See full trace by running task with --trace)
==&amp;gt; Pre-deploy has failed
==&amp;gt; Exited with status 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That was confusing because I did deploy my Render app with a database connection.&lt;/p&gt;

&lt;p&gt;But I did the logical thing which was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check the database existed on Render and was connected via the Environment Variables to my deployed web service. It was!&lt;/li&gt;
&lt;li&gt;Go to the &lt;code&gt;config/database.yml&lt;/code&gt; and see what the connection was expecting...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the &lt;code&gt;config/database.yml&lt;/code&gt;, I found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;primary&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;primary_production&lt;/span&gt;
    &lt;span class="na"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*default&lt;/span&gt;
    &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;news_production&lt;/span&gt;
    &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;news&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;%= ENV["NEWS_DATABASE_PASSWORD"] %&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Oops! By default, when I created my app Rails 8 app with &lt;code&gt;rails new ...&lt;/code&gt;, it set the production database.&lt;/p&gt;

&lt;p&gt;But what I actually want in those lines is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;span class="na"&gt;production&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;primary&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;primary_production&lt;/span&gt;
    &lt;span class="na"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*default&lt;/span&gt;
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;%= ENV["DATABASE_URL"] %&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I made that change, pushed a commit, and the app is up and running!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webdev</category>
      <category>database</category>
    </item>
    <item>
      <title>Testing out my blog</title>
      <dc:creator>Ben Purinton</dc:creator>
      <pubDate>Thu, 13 Mar 2025 16:52:00 +0000</pubDate>
      <link>https://dev.to/bendirtdev/testing-out-my-blog-5281</link>
      <guid>https://dev.to/bendirtdev/testing-out-my-blog-5281</guid>
      <description>&lt;p&gt;How does it look?&lt;/p&gt;

</description>
      <category>testing</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
