Can someone explain me why "curl: (7) Failed to connect to 127.0.0.1 port 2000: Connection refused" ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can someone explain me why "curl: (7) Failed to connect to 127.0.0.1 port 2000: Connection refused" ?

vergil
Hi!,

I do not understand why it says "curl: (7) Failed to connect to 127.0.0.1
port 2000: Connection refused" :
curl -X POST -F 'first_name=pinco' -F 'last_name=pallo' -F
'company_name=Company' -F 'email=[hidden email]' -F 'tel=111111111'
127.0.0.1:2000/puser/add curl: (7) Failed to connect to 127.0.0.1 port 2000:
Connection refused.

In server-gorillamux.go : CONN_PORT = "2000"

in /etc/nginx/conf.d/default.conf :
 
    upstream golang-webserver {
        ip_hash;
        server 127.0.0.1:2000;
    }

    server {
        #listen 2999;
        server_name ggc.world;

        root /puser/add; // Is this correct?

        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers
EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:50m;

        location / {
            #proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
            proxy_pass http://golang-webserver;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            #proxy_set_header Host $host;
        }
    }

Looking forward to your kind help.
Marco

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,288019,288019#msg-288019

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

RE: Can someone explain me why "curl: (7) Failed to connect to 127.0.0.1 port 2000: Connection refused" ?

Reinis Rozitis
> Subject: Can someone explain me why "curl: (7) Failed to connect to
> 127.0.0.1 port 2000: Connection refused" ?
>
> Hi!,
>
> I do not understand why it says "curl: (7) Failed to connect to 127.0.0.1 port
> 2000: Connection refused" :
> curl -X POST -F 'first_name=pinco' -F 'last_name=pallo' -F
> 'company_name=Company' -F 'email=[hidden email]' -F
> 'tel=111111111'
> 127.0.0.1:2000/puser/add curl: (7) Failed to connect to 127.0.0.1 port 2000:
> Connection refused.
>
> In server-gorillamux.go : CONN_PORT = "2000"


Is the go application/server running?


Since the nginx doesn't listen on 2000 port (and only proxies the connections to backend) it's important that the backend is up.

rr

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Can someone explain me why "curl: (7) Failed to connect to 127.0.0.1 port 2000: Connection refused" ?

vergil
In reply to this post by vergil
I solved it .
It was mix of small little problems that together hindered the correct
answer:
- changed in golang webserver HOST = 127.0.0.1
- capitalized the first letter of each element of the Puser struct in order
to make it visible to json decoder
- used correctly the curl command:

curl -d'{"first_name":"pinco", "last_name":"pallo",
"company_name":"Company","email":"[hidden email]","tel":"111111111"}'
-H "Content-Type: application/json" 127.0.0.1:2000/puser/add
[{"First_name":"pinco","Last_name":"pallo","Country":"","Company_name":"Company","Email":"[hidden email]","Tel":"111111111"}]

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,288019,288023#msg-288023

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx