Lesstep
Bitbucket Data Center · Git over HTTPS · Checked November 22, 2026

Bitbucket Data Center: HTTP access token with Git, "URL rejected: Port number was not a decimal number" and "fatal: Authentication failed"

Git over HTTPS takes an HTTP access token as the password, and three details decide whether it works: the user name that goes with it, whether the token has characters that break a URL, and whether anything in front of the server still passes the sign-in on. The user name differs by kind of token: your own name for a personal token, x-token-auth for a project or repository token. This page is the Git side; the REST API's own refusals are on the "You are not permitted to access this resource" page.

What it looks like

fatal: unable to access 'https://x-token-auth:<token>@<bitbucket-host>/scm/<project>/<repository>.git/': URL rejected: Port number was not a decimal number between 0 and 65535
Password for 'https://<user>@<bitbucket-host>':
fatal: Authentication failed

The same token works in the IDE: Pull Request Inbox for Bitbucket, a plugin for JetBrains IDEs, signs in to Data Center with a personal HTTP access token, kept in the IDE's password safe and sent only to that server.

1. Which user name

From Atlassian's page on HTTP access tokens:

2. "URL rejected: Port number was not a decimal number": encode the token

Atlassian's article: any Data Center version that takes tokens as Basic authentication fails this way when the token contains characters that break URL syntax, for example a / in the token. The token has to be URL-encoded. With jq (the article's command):

echo -n "<token>" | jq -sRr @uri

Use the output in the URL, here as a repository token:

git clone https://x-token-auth:<encoded-token>@<bitbucket-host>/scm/<project>/<repository>.git

The same token, unencoded, works as a Bearer header, which is Atlassian's other answer:

git clone -c http.extraHeader="Authorization: Bearer <token>" https://<bitbucket-host>/scm/<project>/<repository>.git

(In Windows PowerShell, put the header in double quotes as above.) Atlassian lists a known problem with Bearer and Git LFS (BSERV-13613) and recommends Basic authentication for LFS.

3. "Authentication failed": the other causes

In the IDE

Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, works with Bitbucket Data Center 8.9 or later in beta. In Settings | Tools | Pull Request Inbox for Bitbucket you give the server and a token. With the user name empty, the token is sent as a Bearer token, which is what a project or repository token needs. With a user name, it goes in HTTP Basic. When Data Center refuses it, the plugin says that the token expired or was revoked, or that the user name is not the token's user, and that the user name should be left empty for a project or repository token. It does not send a refused token again until you change the token or user name, or press Refresh, because Data Center locks an account after repeated refused sign-ins. The IDE's own Git operations use Git's credentials, not this setting. The review inbox, diffs and discussions are free; approving, commenting and merging are Pro, with a 30-day trial.

Get it on JetBrains Marketplace

Sources

Bitbucket and Atlassian are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.

More: "You are not permitted to access this resource" · "CAPTCHA required" · Bitbucket Git remote URLs · 日本語