Degrees Of Freedom of Spring-mass system 
Consider 2 masses $M_1$ and $M_2$ connected with a spring of stiffness $k$, resting on a smooth frictionless surface. Now, each mass has its own 1 DOF along the $x$-axis. And the system has 1 constraint , i.e. the spring. 
So, in all there should be 2(1)-1= 1 DOF for the system. But I've read that it has 2 actually. So where am I going wrong?
 A: The spring isn't a constraint, since its length can change arbitrarily. Thus, along the $x$-axis there are 2 degrees of freedom.
A: Imagine a system of your two masses $m$ and one spring, spring constant $\kappa$ but with two other spring, spring constant $k$, attached to the masses as shown in the diagram below.  
This system certainly has two degrees of freedom.
You have two masses and a displacement along a straight line for each of the masses with the spring providing the interaction between the masses.  
 
It can be shown that there are two normal modes for this system and the frequencies of these modes are $\omega_1 = \sqrt{\dfrac{k+2\kappa}{m}}$ and $\omega_2 = \sqrt{\dfrac{k}{m}}$
If $k \rightarrow 0$, which is equivalent to not having the two outer springs there, then:  


*

*$\omega_1 \rightarrow \sqrt{\dfrac{2\kappa}{m}}$ which is the motion
about the centre of mass of the system

*$\omega_2 \rightarrow 0$ which is the masses being displaced and/or
given a velocity which would then result in a motion of the centre of
mass of the system with no restoring force.
A: Both m1 and m2 (ie, the system) is a two-dimensional case. Then, m1 and m2 each possess 2 DOF. Hence total DOF of system = 4
No: of constraints on m1= 1
No: of constraints on m2= 1
So, total constraints of the system= 2
Hence, resultant DOF of system= 4-2
=2
