Answers.Body: <p>Ok, so @brad-bell suggested a fix and the solution was to disable <code>::1 localhost</code> rule from my /etc/hosts file. After that change all images are working properly. </p>
  
  <p>More details can be found here <a href="https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80">https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80</a> </p>
  
  <p>Thanks! </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-29T12:50:03.890Z
Answers.LastActivityDate: 2019-07-29T12:50:03.890Z
Answers.UserDisplayName: krzk
Body: <p>All assets on my website work properly, however I cannot resolve an issue with Imager plugin on a single page template.</p>
  
  <p>My template:</p>
  
  <pre><code>    {% set profileImage = entry.user.photoUrl('original') %}
      {% set transform = {width: 90, height: 90, effects: { grayscale: true, gamma: 1.2 } } %}
      {% set transformedImage = craft.imager.transformImage(profileImage, transform|merge({width: 180, height: 180})).getUrl() %}
  
          {% if profileImage %}
              &lt;figure&gt;
                  &lt;span style="background-image: {{transformedImage}}"&gt;
                      &lt;img src="{{ transformedImage }}"/&gt;
                  &lt;/span&gt;
              &lt;/figure&gt;
          {% endif %}
  </code></pre>
  
  <p>When I try to open a page which uses this template I got the Craft Exception: </p>
  
  <blockquote>
    <p>cURL error “7” encountered while attempting to download
    “<a href="http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482" rel="nofollow noreferrer">http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482</a>”.
    The error was: “Failed to connect to 127.0.0.1 port 8001: Connection
    refused”</p>
  </blockquote>
  
  <p>But when I open the image link directly it works normally. Checked permissions many times. What can be an issue here?</p>
  
  <p>Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-25T22:43:28.500Z
Comments.Text: When you open `“http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482` directly it works?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-25T23:05:58.753Z
Comments.Text: Yes, it does. That's why I'm not quite sure what's the issue
Comments.UserDisplayName: krzk
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-25T23:10:58.057Z
Comments.Text: Several things here to try: https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-26T10:20:16.983Z
Comments.Text: Thank you very much!! That was the case - I removed `::1 localhost` from my /etc/hosts and boom - everything works just fine!
Comments.UserDisplayName: krzk
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-26T18:05:03.967Z
Comments.Text: Awesome... would you mind adding what worked for you as an official answer in case it ends up helping someone in the future?
Comments.UserDisplayName: Brad Bell
Tags: <plugin-imager>
Title: Imager - connection refused error
ThreadText: # Imager - connection refused error
  
  (Asked by: username_0 on 2019-07-22)
  
  All assets on my website work properly, however I cannot resolve an issue with Imager plugin on a single page template.
  
  My template:
  
  ```
      {% set profileImage = entry.user.photoUrl('original') %}
      {% set transform = {width: 90, height: 90, effects: { grayscale: true, gamma: 1.2 } } %}
      {% set transformedImage = craft.imager.transformImage(profileImage, transform|merge({width: 180, height: 180})).getUrl() %}
  
          {% if profileImage %}
              <figure>
                  <span style="background-image: {{transformedImage}}">
                      <img src="{{ transformedImage }}"/>
                  </span>
              </figure>
          {% endif %}
  
  ```
  
  When I try to open a page which uses this template I got the Craft Exception:
  
  > cURL error “7” encountered while attempting to download
  > “<http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482>”.
  > The error was: “Failed to connect to 127.0.0.1 port 8001: Connection
  > refused”
  
  But when I open the image link directly it works normally. Checked permissions many times. What can be an issue here?
  
  Thanks
  
  **Tags:** plugin-imager
  
  > **Comments:**
  > **username_1**: When you open `“http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482` directly it works?  
  > **username_0**: Yes, it does. That's why I'm not quite sure what's the issue  
  > **username_1**: Several things here to try: https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80  
  > **username_0**: Thank you very much!! That was the case - I removed `::1 localhost` from my /etc/hosts and boom - everything works just fine!  
  > **username_1**: Awesome... would you mind adding what worked for you as an official answer in case it ends up helping someone in the future?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-07-29. Score: 1 | Accepted answer
  
  Ok, so @username_1 suggested a fix and the solution was to disable `::1 localhost` rule from my /etc/hosts file. After that change all images are working properly.
  
  More details can be found here <https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80>
  
  Thanks!
  
  
  ---
  
  