<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>

CC BY-SA 4.0
2019-07-29T12:50:03.890Z
2019-07-29T12:50:03.890Z
krzk
<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>

CC BY-SA 4.0
2019-07-25T22:43:28.500Z
When you open `“http://127.0.0.1:8001/cpresources/[...]/myImage.jpg/?d=1553875482` directly it works?
Brad Bell
CC BY-SA 4.0
2019-07-25T23:05:58.753Z
Yes, it does. That's why I'm not quite sure what's the issue
krzk
CC BY-SA 4.0
2019-07-25T23:10:58.057Z
Several things here to try: https://stackoverflow.com/questions/22952676/curl-failed-to-connect-to-localhost-port-80
Brad Bell
CC BY-SA 4.0
2019-07-26T10:20:16.983Z
Thank you very much!! That was the case - I removed `::1 localhost` from my /etc/hosts and boom - everything works just fine!
krzk
CC BY-SA 4.0
2019-07-26T18:05:03.967Z
Awesome... would you mind adding what worked for you as an official answer in case it ends up helping someone in the future?
Brad Bell
<plugin-imager>
Imager - connection refused error
# 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 %}
            
                
                    
                
            
        {% 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 @brad-bell 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!


---

