title: Restoring a postgres database I dumped from remote
body: <p>I'm trying to dump and restore a Postgres database hosted on an AWS bastion, using psql. To do that I need to open a SSH tunnel.</p>
  
  <p>I open the tunnel this way:
  <code>ssh -v -A admin@bastion.my.company.name -L 15432:databasename.amazonaws.com:5432 -N</code></p>
  
  <p>Then dump it with:
  <code>pg_dump -v -h 0.0.0.0 -p 15432 -U postgres -d databasename --clean -T tablesINeed &gt; ~/pgdumps/databasenamedump.sql</code></p>
  
  <p>So far so good, I can dum through my tunnel. Then I close the tunnel and try to restore:
  <code>psql -h 0.0.0.0 -p 5432 -U postgres -d databasename &lt; ~/pgdumps/databasenamedump.sql</code></p>
  
  <p>But I get:</p>
  
  <blockquote>
    <p>psql: error: could not connect to server: could not connect to server: Connection refused
        Is the server running on host "0.0.0.0" and accepting
        TCP/IP connections on port 5432?</p>
  </blockquote>
  
  <p>How is that? I probably don't understand dump/restore conceptually? Once I have my dumped db, I simply want to run a local instance of it.
  Am I supposed to use <code>15432</code> (the port I opened for the ssh tunnel) to restore? I'm afraid of trying as this is a production database. I tried looking on psql documentation but didn't find a similar scenario</p>
  
  <p>Thank you for any clarification</p>