Dronekit and MavProxy connection error

Hello I have been trying to connect dronekit with mavproxy. First I started sim_vehicles.py, then on a new terminal I ran the python script for connecting dronekit but it throws an error “Link Timeout, no heartbeat in last 5 sec”. I tried connecting it with both UDP and TCP but it doesn’t seem to connect. Any help would be highly appreciated. Thank You.

Are you connecting on right port?
please share the code so that one can check and tell.

Yes, the port was correct. I solved the issue. The issue was that the timeout had occurred before the copter got all its sensors ready. So increasing the timeout to 120 seconds helped.