On this page
The same mistake in different apps
Every WireGuard app reads the same format, but each words its refusals in its own way. On Linux the line is followed by Configuration parsing error, and spaces are gone from it: Jc = 4 is printed as Jc=4.
An unknown line in
[Interface]Linux, wg and wg-quickLine unrecognized: `Jc=4'
WindowsInvalid key for [Interface] section: "jc"
An unknown line in
[Peer]Linux, wg and wg-quickLine unrecognized: `DNS=1.1.1.1'
WindowsInvalid key for [Peer] section: "dns"
A line above the first section
Linux, wg and wg-quickLine unrecognized
WindowsLine must occur in a section
A wrong key
Linux, wg and wg-quickKey is not the correct length or format
WindowsKeys must decode to exactly 32 bytes, or Invalid key
No private key
Linux, wg and wg-quickThe file is taken, the handshake never happens
WindowsAn interface must have a private key
A peer without a key
Linux, wg and wg-quickA peer is missing a public key
WindowsAll peers must have public keys
Endpointwithout a portLinux, wg and wg-quickUnable to find port of endpoint
WindowsMissing port from endpoint
A bad address in
AllowedIPsLinux, wg and wg-quickAllowedIP is not in the correct format, or Unable to parse IP address
WindowsInvalid IP address
The file's name
Linux, wg and wg-quickThe config file must be a valid interface name, followed by .conf
WindowsTunnel name is not valid
- macOS:
Interface contains unrecognized key ‘Jc’,Peer contains unrecognized key ‘DNS’,Private key is invalid,Public key is invalid. Below the first one the app lists the keys it knows. - Android:
Unknown attribute in Interface,Unknown attribute in Peer,Incorrect key length,Bad characters in key,Invalid namefor the file's name.
Line unrecognized: the line tells the cause
sudo bash -c 'wg setconf wg0 <(wg-quick strip wg0)'strip leaves out the lines only wg-quick knows (Address, DNS, PostUp and others) and hands the rest to wg. The interface must exist.
head -c 3 wg0.conf | od -An -tx1ef bb bf is a BOM, ff fe is UTF-16. A clean file starts with 5b (the bracket) or 23 (the # sign).
sed -i '1s/^\xEF\xBB\xBF//' wg0.confRemoves the BOM. Windows line endings don't have to be fixed: they count as spaces.
Jc,Jmin,Jmax,S1,H1,I1,HeaderProtectionKeyCauseAn AmneziaWG file in a WireGuard app
What to doOpen it in an AmneziaWG client. Deleting the lines doesn't help: the server expects changed packets
Address,DNS,MTU,Table,PostUpCauseThe file was given to
wg setconf, or the line stands under[Peer]What to do
wg-quick up, orwg setconfwithwg-quick strip; move the line under[Interface]Endpoint,PublicKey,AllowedIPsCause
[Peer]is missing above them, or misspelledWhat to doAdd
[Peer], exactly soPrivateKeyorListenPortCauseThey stand under
[Peer]What to doMove them under
[Interface][Interface]itselfCauseInvisible characters in front: the file was saved as UTF-8 with BOM or UTF-16
What to doSave it as plain UTF-8, or use the command below
[Peers],[Server]CauseThere are only two sections,
[Interface]and[Peer]What to doFix the heading
PrivateKeywith a typo, such asPrivatKeyCauseThe name is checked to the letter; capitals don't matter
What to doFix the name
SaveConfigorFwMark, on Windows or a phoneCauseThese are Linux lines, other apps don't know them
What to doDelete the line
PostUp,PreUp, on macOS, iOS or AndroidCauseThese apps run no commands
What to doDelete the line
Which app takes which line
A file that works on a server with wg-quick may be refused by a phone. This is what the code of each official app accepts in [Interface] besides PrivateKey, Address, DNS, MTU and ListenPort, which all of them know.
PreUp,PostUp,PreDown,PostDownwg-quickRuns them
WindowsAccepts; runs only with
DangerousScriptExecutionin the registrymacOS and iOSRefuses the file
AndroidRefuses the file
Tablewg-quickYes
WindowsYes
macOS and iOSRefuses the file
AndroidRefuses the file
FwMark,SaveConfigwg-quickYes
WindowsRefuses the file
macOS and iOSRefuses the file
AndroidRefuses the file
IncludedApplications,ExcludedApplicationswg-quickRefuses the file
WindowsRefuses the file
macOS and iOSRefuses the file
AndroidYes
Jc,S1,H1and other AmneziaWG lineswg-quickRefuses the file
WindowsRefuses the file
macOS and iOSRefuses the file
AndroidRefuses the file
Key is not the correct length or format
A WireGuard key is 32 bytes written in base64: always 44 characters, the last one =. The program counts exactly that, so anything else gives the error, and the text after it is what it read in place of a key. Windows says the same as Keys must decode to exactly 32 bytes or Invalid key: illegal base64 data at input byte.
sudo awk '/Key *=/ {sub(/^[^=]*= */, ""); print length($0)}' /etc/wireguard/wg0.confThe length of each key in the file, in order. Every number must be 44: trailing spaces count too, so a 45 may be just a space.
echo "KEY" | wg pubkeyKEY is the key being checked. A line of 44 characters in reply: the format is right. An error: it isn't. For a private key the reply is its public key.
- A placeholder was left in:
<client private key>orCLIENT_KEYfrom an example. - The
=was cut off. A double click in a terminal often selects a key without its last character. - A path instead of a key. In a file the key itself stands after
PrivateKey. A path is what the command takes:wg set wg0 private-key /etc/wireguard/server.key. - The words
(hidden).wg showhides private keys; the real one is in the file or insudo wg show wg0 private-key. - Quotes or brackets around it. The format has none.
- Keys of another kind: an SSH key, a Reality key (43 characters, no
=), a hex string of 64 characters. wg: Key is not the correct length or formatwith nothing after it comes fromwg pubkey: it was given an empty line or the wrong file.
Tunnel name is not valid
The tunnel gets its name from the file. On Linux and Android it is up to 15 characters, on Windows up to 32: Latin letters, digits and _ = + . -. Spaces, brackets and other alphabets are out, so a second download named wg0 (1).conf is refused, and so is a file named after a city in Cyrillic. On Windows names such as con, nul and com1 are taken by the system. Rename the file and import it again.
Other messages about values
Warning: AllowedIP has nonzero host partis a warning, not an error:10.8.0.2/24is read as the network10.8.0.0/24. For one device write/32.Persistent keepalive interval is neither 0/off nor 1-65535: one number of seconds is needed. A range such as22-30is from AmneziaWG 3.Two commas in a row(Windows): an extra comma inAllowedIPs,AddressorDNS, at the end of the line too.Brackets must contain an IPv6 address(Windows): an IPv6 address inEndpointgoes in square brackets,[2001:db8::1]:51820.Invalid MTU(Windows): from 576 to 65535.Name or service not known: the name inEndpointdoesn't exist; put the server's IP there.
Find it faster
The WireGuard config checker on this site, /tools/wireguard-check/, reads the file in the browser and lists every mistake with its line: keys, sections, Endpoint, AllowedIPs, AmneziaWG lines. It can't see one thing, whether the keys belong to each other: a file may be flawless, and the handshake still doesn't happen because the server doesn't know the client's key. That is another guide, on Handshake did not complete.