title: Unable to connect containerized app to containerized postgres, receiving dial tcp connection refused error
body: <p>This community is my last resort for this problem, as I have been fighting with this for several hours now.</p>
  
  <p>I have a go app running in one container, in the other container I am running a postgres db. I am able to connect to the postgres db from my go application as long as <strong>only</strong> my postgres is within a container, and my go app is running locally as usual. However, when my go app is trying to access the postgres from within a docker container i am getting the following <strong>error</strong>:</p>
  
  <pre><code>dial tcp 127.0.0.1:8080: connect: connection refused 
  </code></pre>
  
  <p>Below I try to provide enough information, but will gladly add more if requested.</p>
  
  <hr>
  
  <p>I have 2 docker containers running with the following <strong>ports</strong>:</p>
  
  <ul>
  <li>go application, port info: 8081/tcp -> 0.0.0.0:8081</li>
  <li>postgres db, port info: 5432/tcp -> 0.0.0.0:8080</li>
  </ul>
  
  <hr>
  
  <p>I am <strong>running</strong> the go app with:</p>
  
  <pre><code>docker run -it --rm --name gographqlserver --link postgresdb:postgres -d -p 8081:8081 gogogopher;
  </code></pre>
  
  <p>and the postgres db with:</p>
  
  <pre><code>docker run -it --rm --name postgresdb -e POSTGRES_PASSWORD=hello123 -d -p 8080:5432 postgresimage;
  </code></pre>
  
  <p>both containers can be started without any problems.</p>
  
  <hr>
  
  <p>I have also tried <strong>connecting</strong> both containers within a <code>docker network</code>, which did not help.</p>
  
  <hr>
  
  <p>help would be immensely appreciated!</p>