There is gravity everywhere. It gives shape to the orbits of the planets, the solar system, and even galaxies. Gravity from the Sun reaches throughout the solar system and beyond, keeping the planets in their orbits. Gravity from Earth keeps the Moon and human-made satellites in orbit.
It is true that gravity decreases with distance, so it is possible to be far away from a planet or star and feel less gravity. But that doesn't account for the weightless feeling that astronauts experience in space. The reason that astronauts feel weightless actually has to do with their position compared to their spaceship. We feel weight on Earth because gravity is pulling us down, while the floor or ground stop us from falling. We are pressed against it. Any ship in orbit around the Earth is falling slowly to Earth. Since the ship and the astronauts are falling at the same speed, the astronauts don't press against anything, so they feel weightless.