Answers: <p>If the system recently rebooted and your proxy server is giving 502/503s, it's most likely that the backend service failed to start.</p>
  
  <p>Using whatever tools are most appropriate for your OS/distro (e.g. <code>systemctl</code>, <code>service</code>/<code>chkconfig</code>, <code>stop</code>/<code>start</code>/<code>restart</code>/etc.), do the following things:</p>
  
  <ul>
  <li>Verify that the backend (in this case Jenkins) is configured to start on boot.  Enable it if not.</li>
  <li>Start the backend.</li>
  <li>If the backend fails to start, check the application logs to find the source of the error.  For Jenkins on Linux, this would be <code>/var/log/jenkins/jenkins.log</code>.</li>
  </ul>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-28T07:50:30.950Z
Answers: All the services, nginx and jenkins are up and running, jenkins is started on boot, but still I got the same errors.
Answers: spacetrack
Answers: CC BY-SA 4.0
Answers: 2019-11-03T03:08:39.433Z
Answers: same here, i know it's been a long time since this has been posted, but have you found the solution?
Answers: Joseph K.
Answers: CC BY-SA 4.0
Answers: 2020-09-24T09:47:07.243Z
Answers: @JosephK. did you find a solution?
Answers: FooBar
Answers: CC BY-SA 3.0
Answers: 2018-03-27T15:59:19.100Z
Answers: 2018-03-27T15:59:19.100Z
Answers: jayhendren
Body: <p>So my server got maintenance schedule from cloud provider, after maintenance process, the server rebooted, then my jenkins cannot be accessed from the web anymore, I am using nginx and checking the logs I found this.</p>
  
  <blockquote>
    <p>/var/log/nginx/error.log</p>
  </blockquote>
  
  <pre><code>2018/03/26 16:11:00 [error] 21689#21689: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 139.139.139.139, server: jenkins.domain.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "jenkins.domain.com"
  
  2018/03/26 16:11:00 [error] 21689#21689: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 139.139.139.139, server: jenkins.domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "jenkins.domain.com", referrer: "http://jenkins.domain.com/"
  </code></pre>
  
  <p>here is my nginx conf file:</p>
  
  <pre><code>upstream app_server {
  server 127.0.0.1:8080 fail_timeout=0;
  }
  
  
  
  server {
    listen 80;
    server_name jenkins.domain.com;
    root /var/www/jenkins.domain.com;
  
    location ~ /\.well-known/acme-challenge {
          default_type "text/plain";
    }
  
    location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
  
          if (!-f $request_filename) {
              proxy_pass http://app_server;
              break;
          }
      }
  }
  </code></pre>
  
  <p>What is the cause of this and maybe what can I do to fix this? Really need your help guys.</p>
  
  <p>Thanks</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-04-11T14:12:23.690Z
Comments: Got same problem. Did you find a solution? I tried already most of the stuff that come up on google, but still struggling
Comments: Lukino
Comments: CC BY-SA 4.0
Comments: 2020-09-24T09:46:49.913Z
Comments: @Lukino did you ever find a solution?
Comments: FooBar
Comments: CC BY-SA 4.0
Comments: 2020-09-25T18:37:45.060Z
Comments: @FooBar Hmm, it is a while, but I managed to get my Jenkins running behind Nginx. (to be a little bit more specific, I got Nginx, Jenkins and Nexus running as Docker containers on the Physical server...
Comments: Lukino
Tags: <jenkins><nginx>
Title: Jenkins returns 502 gateway error and (104: Connection reset by peer)
UserDisplayName: spacetrack
ThreadText: # Jenkins returns 502 gateway error and (104: Connection reset by peer)
  
  (Asked by: username_0 on 2018-03-27)
  
  So my server got maintenance schedule from cloud provider, after maintenance process, the server rebooted, then my jenkins cannot be accessed from the web anymore, I am using nginx and checking the logs I found this.
  
  > /var/log/nginx/error.log
  
  ```
  2018/03/26 16:11:00 [error] 21689#21689: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 139.139.139.139, server: jenkins.domain.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "jenkins.domain.com"
  
  2018/03/26 16:11:00 [error] 21689#21689: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 139.139.139.139, server: jenkins.domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "jenkins.domain.com", referrer: "http://jenkins.domain.com/"
  
  ```
  
  here is my nginx conf file:
  
  ```
  upstream app_server {
  server 127.0.0.1:8080 fail_timeout=0;
  }
  
  server {
    listen 80;
    server_name jenkins.domain.com;
    root /var/www/jenkins.domain.com;
  
    location ~ /\.well-known/acme-challenge {
          default_type "text/plain";
    }
  
    location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
  
          if (!-f $request_filename) {
              proxy_pass http://app_server;
              break;
          }
      }
  }
  
  ```
  
  What is the cause of this and maybe what can I do to fix this? Really need your help guys.
  
  Thanks
  
  **Tags:** jenkins, nginx
  
  > **Comments:**
  > **username_1**: Got same problem. Did you find a solution? I tried already most of the stuff that come up on google, but still struggling  
  > **username_2**: @username_1 did you ever find a solution?  
  > **username_1**: @username_2 Hmm, it is a while, but I managed to get my Jenkins running behind Nginx. (to be a little bit more specific, I got Nginx, Jenkins and Nexus running as Docker containers on the Physical server...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2018-03-27. Score: 2 | Accepted answer
  
  If the system recently rebooted and your proxy server is giving 502/503s, it's most likely that the backend service failed to start.
  
  Using whatever tools are most appropriate for your OS/distro (e.g. `systemctl`, `service`/`chkconfig`, `stop`/`start`/`restart`/etc.), do the following things:
  
  * Verify that the backend (in this case Jenkins) is configured to start on boot. Enable it if not.
  * Start the backend.
  * If the backend fails to start, check the application logs to find the source of the error. For Jenkins on Linux, this would be `/var/log/jenkins/jenkins.log`.
  
  > **Comments:**
  > **username_0**: All the services, nginx and jenkins are up and running, jenkins is started on boot, but still I got the same errors.  
  > **username_4**: same here, i know it's been a long time since this has been posted, but have you found the solution?  
  > **username_2**: @JosephK. did you find a solution?  
  
  ---
  
  