Bitbucket Api call on private repository working for local machine but not from remote server

I have a strange problem. I have some code (PHP) that requests information from a private repository using BitBucket's API. When I make the request from localhost (my local server – apache2) I have no problem.

However, when I make the same request from my remote server (I.e. My live website I get a 403 forbidden).

I'm not sure why it's working in one place and not in another.

Therefore, I was wondering if requests from the ip address of my remote server are somehow being blocked or if that ip address has been whitelisted for some reason.

The code (which, again works fine from my localhost) is pasted below:

function bitBucketConnect($url){
global $bitPassword;
global $bitUsername;
$context = stream_context_create(array
( 'http' => array(
'header' => "Authorization: Basic " . base64_encode("$bitUsername:$bitPassword")			))	

//Make the request
return file_get_contents($url, false, $context);


I can further report that, when the bitBucket repository is PUBLIC/NOT PRIVATE this will successfully retrieve data on the remote server. But the whole point of using the authorization header is to be able to access a private repository. And this is where I get the 403 Forbidden response. (But again, on my local machine, I have sucess when the Repo is either public or private).

I very much appreciate any assistance you can give me.

2 answers

0 votes

To be clear, we don't block IP addresses unless there is some severe abuse. There is likely a configuration problem with the server. I'll leave that to the community to help troubleshoot.

I have received the following response from hosting company:

Unfortunately, BitBucket is not supported on our servers as it requires ffmpeg (which is not supported).

I don't understand how supporting "ffmpeg" could be relevant to api requests and authorization at issue.

Does that response make sense to anyone?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,923 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you