Article snapshot taken from Wikipedia with creative commons attribution-sharealike license.
Give it a read and then ask your questions in the chat.
We can research this topic together.
Currently there is no operational railway crossings between Pakistan and Afghanistan, However Pakistan Railways was planning to lay new railway track between two countries to boost business activities.
The Khunjerab Pass is the only modern-day border crossing between China and Pakistan which can be accessed via the Karakoram Highway. The actual immigration of the respective countries is cleared in Sost, Pakistan and Tashkurgan, China, around 100 kilometres (62 mi) from the Khunjerab Pass. Historically, the Mintaka Pass and Kilik Pass have also been used; however those crossings do not have vehicle access and are closed.
Proposed
A border crossing near Mustagh Pass has been proposed as an alternative CPEC route in order to shorten the route to China, which would also connect AJ&K.