(13: Permission denied) while connecting to upstream while configuring Ngnix

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Problem

While configuring Bitbucket to use Ngnix as a reverse proxy by following Securing Bitbucket Server behind nginx using SSL the following error appears in Ngnix error log:

1 2016/02/03 17:47:37 [crit] 26894#0: *1 connect() to 127.0.0.1:7990 failed (13: Permission denied) while connecting to upstream, client: 192.168.1.7, server: bitbucket.example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:7990/favicon.ico", host: "bitbucket.example.com", referrer: "http://bitbucket.example.com/"

Diagnosis

Environment

  • Any Linux distribution that ships with SELinux

Diagnostic Steps

Check for errors in the SELinux logs:

1 sudo cat /var/log/audit/audit.log | grep nginx | grep denied

Cause

SELinux prevent connections on port 7990 for the nginx process.

Solution

Resolution

Execute the following command in your server:

1 2 sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx sudo semodule -i mynginx.pp

Refer to http://stackoverflow.com/questions/23948527/13-permission-denied-while-connecting-to-upstreamnginx for more info.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.