title: import postgres db into new AWS
body: <p>I have a postgres db that I have been able to dump and restore to other postgres installs without issue using:</p>
  
  <pre><code>pg_dump the_db_name &gt; the_backup.sql
  </code></pre>
  
  <p>Then copy the backup to your development server, restore with:</p>
  
  <pre><code>psql the_new_dev_db &lt; the_backup.sql
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/1237725/copying-postgresql-database-to-another-server">h/t to this link for that gem.</a></p>
  
  <p>I've also been able to setup and configure ec2, s3 and eb (elastic beanstalk) installs for wordpress, ruby &amp; node js needs. However, I'm staring into the abyss trying to import a postgres db into an amazon rds instance. I suspect this is not a psql problem but a security one. Any suggestions on what to try I'd greatly appreciate it.</p>
  
  <p>I connect to aws using a .pem file. </p>
  
  <p>I can configure pgAdmin to use an ssh tunnel to connect to my rds instance.</p>
  
  <p>I cannot connect to my postgres db on AWS using psql <a href="http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html" rel="nofollow noreferrer">nor can I configure pgAdmin to connect to my db in the way AWS recommends.</a></p>
  
  <p>In both of these cases I get the error:</p>
  
  <pre><code>psql: could not connect to server: Connection timed out
      Is the server running on host "xxxxxxx.us-west-2.rds.amazonaws.com" (xx.xx.xx.xx) and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  
  <p>In the rds dashboard I see my instance is part of two security groups. When I click on one it says: </p>
  
  <pre><code>Your account does not support the EC2-Classic Platform in this region. DB Security Groups are only needed when the EC2-Classic Platform is supported. Instead, use VPC Security Groups to control access to your DB Instances. Go to the EC2 Console to view and manage your VPC Security Groups. For more information, see AWS Documentation on Supported Platforms and Using RDS in VPC
  </code></pre>
  
  <p>When I click on the other Security Group and go to its Inbound tab I see there are two references that show Postgresql is receiving TCP on port 5432</p>
  
  <p>Also in the RDS dashboard I see I have a VPC ID, <a href="http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.FindDefaultVPC.html" rel="nofollow noreferrer">but after reading this article</a>, I'm not sure which way to go because there is no field for "Supported Platforms." </p>
  
  <p>If I try to do a restore from the working config in pgAdmin I get a similar message as the connection one:</p>
  
  <pre><code>pg_restore: [archiver (db)] connection to database "ebdb" failed: could not connect to server: Connection timed out
      Is the server running on host "XXXX.us-west-2.rds.amazonaws.com" (54.148.0.217) and accepting
      TCP/IP connections on port 5432?
  </code></pre>
  
  <p>Finally, I've tried to bring up the PSQL console in the db in pgAdmin. It comes up and I can run psql commands like:</p>
  
  <pre><code>ebdb=&gt; \conninfo
  You are connected to database "ebdb" as user "awsuser" on host "127.0.0.1" at port "34883".
  SSL connection (protocol: TLSv1.2, cipher: XXXX, bits: 256, compression: off)
  </code></pre>
  
  <p>However, if I try to run pg_restore here using this command:    </p>
  
  <pre><code>ebdb=&gt; \! /usr/bin/pg_restore --dbname "ebdb" --section pre-data --section data --section post-data --create --clean --verbose "/home/awsuser/040517.backup"
  </code></pre>
  
  <p>it does not create any tables or push in any data. The console lites up and flashes all the SQL commands and the data as though it worked, but when I go back into pgAdmin and look it is still empty.</p>