How does KiCad know which symbol pin represents which pad of the footprint?

KiCad needs to know which pin of the symbol represents which footprint pad when creating the connectivity information of the board. See also: What is the difference between footprints and symbols?

The identification is done with the help of the symbols pin numbers and footprints pad numbers. These must agree with each other. (Every symbol pin must have at least one footprint pad where the symbol pin number is the same as the footprint pad number.)

This is easier to see in an example:

Note that it is possible to have more pads in the footprint than in the symbol. These pads will simply be left unconnected.
The other way round will result in an error message. (Do not ignore this message as it is the only check ensuring that layout and schematic are equal.)

  • Error: Component "[component reference]" pad "[the pin number]" not found in footprint: "[footprint name]"
  • As an example assigning a 5 pin connector footprint for a JST B05B-EH-A to a 6 pin symbol (J3) will result in the following error message: Error: Component J3 pad 6 not found in footprint Connector_JST:JST_EH_B05B-EH-A_1x05_P2.50mm_Vertical

You will get the same error message if the pin numbers are different than the pad numbers (even if the pin and pad count are equal). The error message is the same no matter if the pin responsible for the missing pad is connected to anything or if it is free floating.

An example of the pin and pad setup within their properties dialogs is shown here:

The footprint can have pads that are not used in the symbol. These will be handled in the same manner as if they appear in the symbol but were left unconnected.

It is possible to assign the same pad number to multiple pads inside the same footprint. KiCad will assign the same net to all of them and force you to connect them within your layout. (If they overlap KiCad will notice that and you will not need to connect them with a trace. This fact is used in the official library to add thermal vias to footprints that need them.)
If you do not want this behavior then you need to assign different pad numbers to these pads and add a pin for each of them in the symbol. (Only makes sense if the pads in question have enough clearance between them.)

Further reading:

Ultra Librarian Part has Symbol&Footprint - Missing Pins
Footprint not finding pads
Not driven errors
Sorting the Pin Table BY UNIT
Possible to permantly tie footprint pad to net?
P Channel Mosfet symbols and footprints
RJ45 will not connect
Beginner question about symbols and footprints
Not found in footprint Connector
Footprint not connected to Symbol
Blog about how to make library assets
USB_B_V footprint error(Component not found in footprint)
ERROR: Component ''pad '' not found in footprint
Using Arduino_Uno_R3 - CAD newby
Pcbnew failing to load components unless I start a new board
Doubts when using the LM324
Conn_02x16_Row_Letter_Last no similar footprint?
One symbol not in list (CvPcb)
KiCad EDA Newb Needs Help Getting Started
Does this footprint work for you?
Looking for Tutorial that goes through simple schematic to board
Matching (Reconciliation) the Footprint with its Symbol
The mapping between symbol and footprint is fixed. Correct?
Tutorial: How to make a symbol (KiCad v5.1.x)
How to make such a wierd switch-footprint
Problem routing nets after I flip a part
More trouble (pcbnew bug?) with filled zones
Footprint editor frustration- 15 resistor DIP array
Problems with direction of potentiometer
[Solved] Routing problem
Assign Footprints 'Apply, Save Schematic & Continue' What does it do?
Looking for various footprints (ATMega)
Looking for thru-hole tactile switch with LED
Trying to create a PCB with holes
High level thinking
High level thinking
Error in reading netlist
Track connections
Toggle switch tutorial
Wire connection problem
P-Channel Mosfet (DSG) -> (GSD)
Connector pin assignement
(Start Here) Frequently Asked Questions
Tutorial: How to make a footprint in KiCad 5.1.x?
Problems associating custom footprints to symbols
Newbee Symbol Shows no Connections to Footprint
Tutorial: How to make a footprint in KiCad 5.1.x?
"fixing" the pin assignments on a symbol and footrpint
I get an error on PCBnew
Where's the Molex male connectors?
Netlist not populating properly
How can I resolve these errors?
No footprint assigned
Is my Schottky diode symbol reversed in my F.Fab layer? [solved]
Footprint not finding pads
Some thoughts on the underlying data model (symbols)