The 0-1 knapsack problem is one of the classic NP-hard problems. It is an open issue in discrete optimization problems, which plays an important role in the real applications. Therefore, several algorithms have been developed to solve it. The Gravitational Search Algorithm (GSA) is an optimization algorithm based on the law of gravity and mass interactions. In the GSA, the searcher agents are a collection of masses that interact with each other based on the Newtonian gravity and the laws of motion. In this algorithm the position of the agents can be considered as the solutions. The GSA is a nature-inspired algorithm that is used for finding the optimum value of continuous functions. This paper introduces a Discrete version of the GSA (DGSA) for solving 0-1 knapsack problem. In this regard, we introduce an approach for discretely updating the position of each agent. In addition, a fitness function has been proposed for 0-1 knapsack problem. Our experimental results show the effectiveness of the DGSA in comparison with other similar algorithms in terms of the accuracy and overcoming the defect of local convergence.