At four months, he doesn't know when he has to go. The nerves necessary for advance warning don't develop until around 6 months. Housetraining is all about management and setting up good habits. Take him out every 1.5-2 hours, right after waking and after meals. You will have to wake up a few times at night for while, too. Go outside and don't play. Play time comes after potty time. When he goes outside, praise him and give him a wonderful treat. When he goes inside, smack yourself on the forehead and clean it up with an enzymatic cleaner like Nature's Miracle. (soap and water isn't enough to remove the smell. if he can smell it, he'll consider that place a good place to go.)
This is really just about patience. He'll grow and it will get easier.
This is really just about patience. He'll grow and it will get easier.