---
name: "CURLOPT_DISALLOW_USERNAME_IN_URL"
section: "3"
platform: "linux"
package: "curl"
version: "8.23.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/CURLOPT_DISALLOW_USERNAME_IN_URL"
---

# CURLOPT\_DISALLOW\_USERNAME\_IN\_URL(3)

disallow specifying username in the URL

## NAME

CURLOPT\_DISALLOW\_USERNAME\_IN\_URL - disallow specifying username in the URL

## SYNOPSIS

```
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_DISALLOW_USERNAME_IN_URL,
                          long disallow);
```

## DESCRIPTION

A long parameter set to 1 tells the library to not allow URLs set with *[CURLOPT\_URL(3)](/CURLOPT_URL/3.md)* that include a username.

This is the equivalent to the *CURLU\_DISALLOW\_USER* flag for the *[curl\_url\_set(3)](/curl_url_set/3.md)* function.

Note that this option does not affect URLs set with *[CURLOPT\_CURLU(3)](/CURLOPT_CURLU/3.md)*.

## DEFAULT

0 (disabled)

## PROTOCOLS

This functionality affects all supported protocols

## EXAMPLE

```
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_DISALLOW_USERNAME_IN_URL, 1L);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}
```

## AVAILABILITY

Added in curl 7.61.0

## RETURN VALUE

*[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)* returns a CURLcode indicating success or error.

CURLE\_OK (0) means everything was OK, non-zero means an error occurred, see *[libcurl-errors(3)](/libcurl-errors/3.md)*.

*[curl\_easy\_perform(3)](/curl_easy_perform/3.md)* returns CURLE\_LOGIN\_DENIED if this option is enabled and a URL containing a username is specified.

## SEE ALSO

[**CURLOPT\_PROTOCOLS\_STR**(3)](/CURLOPT_PROTOCOLS_STR/3.md), [**CURLOPT\_URL**(3)](/CURLOPT_URL/3.md), [**curl\_url\_set**(3)](/curl_url_set/3.md), [**libcurl-security**(3)](/libcurl-security/3.md)
