Skip to content
MtrXTools

curl: (3) URL using bad/illegal format or missing URL

curl could not parse the URL

Seen in curl, libcurl (CURLE_URL_MALFORMAT), PHP and other libcurl bindings

curl rejected the URL before connecting because it is empty, malformed or contains characters it cannot use.

Common causes

  • Spaces, smart quotes or stray characters in the URL, often from copying out of a document or chat.
  • Shell quoting problems, such as Windows cmd not treating single quotes as quotes, so they end up in the URL.
  • Unescaped [ ] or { } in the URL, which curl treats as globbing ranges.
  • A variable in a script expanded to an empty string, so no URL was passed at all.

How to fix it

  1. Wrap the URL in double quotes and retype any curly quotes as straight ones.
  2. Percent-encode spaces (%20) and other special characters in the path and query.
  3. Use -g (--globoff) when the URL legitimately contains [ ] or { }.
  4. Echo the variable before the curl call to check it holds a full URL with a scheme.

Got a different message? Paste it into the error explainer.

Related errors

All 34 Command line & code errors