The functional nanoparticles with specific molecular probe appear to be a promising approach for developing colorimetric nanosensor. In this work, we have synthesized tryptophan capped gold nanoparticles (AuNPs) and used to establish colorimetric detection of magnesium (Mg2+). The colorimetric response of the AuNPs toward Mg2+ was noticed with naked eyes, and spectral changes were monitored by using UV-Vis spectrophotometer. The detection response was rapid (less than 1 min), with a detection limit (LOD) about 0.2 µmol L−1. The proposed nanoprobe shows characteristic red-shift of the AuNPs at 620 nm and high selectivity for Mg2+ due to the binding affinity of the tryptophan with Mg2+. The real-time response of the UV-Vis spectrum was monitored at three different concentrations of Mg2+ (0.45, 0.50, and 0.55 µmol L−1). The AuNPs probe was suitable to provide a molecular platform for selective coordination with Mg2+ over Ca2+ ions, thus it could be facile to establish a practically viable sensing system. Furthermore, experimental results were confirmed to exhibit excellent linear curve for urine and serum samples spiked with Mg2+. Thus, this nanosensor is practically useful for the detection of Mg2+, without using expensive instruments, enzymes and/or DNA molecules.